Python samples adapted for Python3 compatibility

Common fixes:
- print function
- int / float division
- map, zip iterators in py3 but lists in py2

Known bugs with opencv 3.0.0
- digits.py, called via digits_video.py: https://github.com/Itseez/opencv/issues/4969
- gaussian_mix.py: https://github.com/Itseez/opencv/pull/4232
- video_v4l2.py: https://github.com/Itseez/opencv/pull/5474

Not working:
- letter_recog.py due to changed ml_StatModel.train() signature
This commit is contained in:
flp
2015-12-13 02:43:58 +01:00
parent 5cdf0e3e89
commit 4ed2d6328b
23 changed files with 218 additions and 131 deletions

View File

@@ -14,6 +14,7 @@ Usage:
from __future__ import print_function
import cv2
import numpy as np
# relative module
import video
@@ -45,7 +46,7 @@ if __name__ == '__main__':
thrs2 = cv2.getTrackbarPos('thrs2', 'edge')
edge = cv2.Canny(gray, thrs1, thrs2, apertureSize=5)
vis = img.copy()
vis /= 2
vis = np.uint8(vis/2.)
vis[edge != 0] = (0, 255, 0)
cv2.imshow('edge', vis)
ch = cv2.waitKey(5) & 0xFF