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

@@ -4,6 +4,9 @@
Utility for measuring python opencv API coverage by samples.
'''
# Python 2/3 compatibility
from __future__ import print_function
from glob import glob
import cv2
import re
@@ -13,7 +16,7 @@ if __name__ == '__main__':
found = set()
for fn in glob('*.py'):
print ' --- ', fn
print(' --- ', fn)
code = open(fn).read()
found |= set(re.findall('cv2?\.\w+', code))
@@ -23,4 +26,4 @@ if __name__ == '__main__':
f.write('\n'.join(sorted(cv2_unused)))
r = 1.0 * len(cv2_used) / len(cv2_callable)
print '\ncv2 api coverage: %d / %d (%.1f%%)' % ( len(cv2_used), len(cv2_callable), r*100 )
print('\ncv2 api coverage: %d / %d (%.1f%%)' % ( len(cv2_used), len(cv2_callable), r*100 ))