mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
samples: fix python samples compatibility with demo.py
This commit is contained in:
@@ -7,6 +7,7 @@ Loads several images sequentially and tries to find squares in each image.
|
||||
'''
|
||||
|
||||
# Python 2/3 compatibility
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
@@ -42,7 +43,7 @@ def find_squares(img):
|
||||
squares.append(cnt)
|
||||
return squares
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
from glob import glob
|
||||
for fn in glob('../data/pic*.png'):
|
||||
img = cv.imread(fn)
|
||||
@@ -52,4 +53,11 @@ if __name__ == '__main__':
|
||||
ch = cv.waitKey()
|
||||
if ch == 27:
|
||||
break
|
||||
|
||||
print('Done')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__)
|
||||
main()
|
||||
cv.destroyAllWindows()
|
||||
|
||||
Reference in New Issue
Block a user