Various Python samples updated for Python 2/3 compatibility.

This commit is contained in:
Adam Gibson
2015-09-14 00:00:22 +08:00
parent 190d00ea3e
commit b57be28920
34 changed files with 288 additions and 99 deletions

View File

@@ -14,6 +14,9 @@ gabor_threads.py [image filename]
'''
# Python 2/3 compatibility
from __future__ import print_function
import numpy as np
import cv2
from multiprocessing.pool import ThreadPool
@@ -48,7 +51,7 @@ if __name__ == '__main__':
import sys
from common import Timer
print __doc__
print(__doc__)
try:
img_fn = sys.argv[1]
except:
@@ -56,7 +59,7 @@ if __name__ == '__main__':
img = cv2.imread(img_fn)
if img is None:
print 'Failed to load image file:', img_fn
print('Failed to load image file:', img_fn)
sys.exit(1)
filters = build_filters()
@@ -66,7 +69,7 @@ if __name__ == '__main__':
with Timer('running multi-threaded'):
res2 = process_threaded(img, filters)
print 'res1 == res2: ', (res1 == res2).all()
print('res1 == res2: ', (res1 == res2).all())
cv2.imshow('img', img)
cv2.imshow('result', res2)
cv2.waitKey()