From 9164ccbaafcd9fe47b10ed143266370f5f319f49 Mon Sep 17 00:00:00 2001 From: Gary Bradski Date: Wed, 14 Mar 2012 21:46:34 +0000 Subject: [PATCH] added 0xFF & in front of every waitKey so that it works on linux --- samples/python2/camshift.py | 2 +- samples/python2/coherence.py | 2 +- samples/python2/color_histogram.py | 2 +- samples/python2/contours.py | 2 +- samples/python2/distrans.py | 2 +- samples/python2/facedetect.py | 2 +- samples/python2/feature_homography.py | 2 +- samples/python2/find_obj.py | 2 +- samples/python2/floodfill.py | 2 +- samples/python2/gaussian_mix.py | 2 +- samples/python2/inpaint.py | 2 +- samples/python2/lk_homography.py | 2 +- samples/python2/lk_track.py | 2 +- samples/python2/morphology.py | 2 +- samples/python2/motempl.py | 4 ++-- samples/python2/mser.py | 4 ++-- samples/python2/opt_flow.py | 2 +- samples/python2/peopledetect.py | 2 +- samples/python2/squares.py | 4 ++-- samples/python2/turing.py | 2 +- samples/python2/video.py | 2 +- samples/python2/watershed.py | 2 +- 22 files changed, 25 insertions(+), 25 deletions(-) diff --git a/samples/python2/camshift.py b/samples/python2/camshift.py index 1973bb8..ea8ac03 100644 --- a/samples/python2/camshift.py +++ b/samples/python2/camshift.py @@ -101,7 +101,7 @@ class App(object): cv2.imshow('camshift', vis) - ch = cv2.waitKey(5) + ch = 0xFF & cv2.waitKey(5) if ch == 27: break if ch == ord('b'): diff --git a/samples/python2/coherence.py b/samples/python2/coherence.py index 6b5a1fd..984f210 100644 --- a/samples/python2/coherence.py +++ b/samples/python2/coherence.py @@ -65,7 +65,7 @@ if __name__ == '__main__': cv2.imshow('src', src) update() while True: - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == ord(' '): update() if ch == 27: diff --git a/samples/python2/color_histogram.py b/samples/python2/color_histogram.py index f2deb84..c5d0ae8 100644 --- a/samples/python2/color_histogram.py +++ b/samples/python2/color_histogram.py @@ -42,6 +42,6 @@ if __name__ == '__main__': vis = hsv_map*h[:,:,np.newaxis] / 255.0 cv2.imshow('hist', vis) - ch = cv2.waitKey(1) + ch = 0xFF & cv2.waitKey(1) if ch == 27: break diff --git a/samples/python2/contours.py b/samples/python2/contours.py index b546e58..f0a5ae6 100644 --- a/samples/python2/contours.py +++ b/samples/python2/contours.py @@ -45,4 +45,4 @@ if __name__ == '__main__': update(3) cv2.createTrackbar( "levels+3", "contours", 3, 7, update ) cv2.imshow('image', img) - cv2.waitKey() \ No newline at end of file + 0xFF & cv2.waitKey() diff --git a/samples/python2/distrans.py b/samples/python2/distrans.py index 8633e66..3301b76 100644 --- a/samples/python2/distrans.py +++ b/samples/python2/distrans.py @@ -44,7 +44,7 @@ if __name__ == '__main__': while True: - ch = cv2.waitKey(50) + ch = 0xFF & cv2.waitKey(50) if ch == 27: break if ch == ord('v'): diff --git a/samples/python2/facedetect.py b/samples/python2/facedetect.py index 20bce3d..a84ab60 100644 --- a/samples/python2/facedetect.py +++ b/samples/python2/facedetect.py @@ -54,6 +54,6 @@ if __name__ == '__main__': draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000)) cv2.imshow('facedetect', vis) - if cv2.waitKey(5) == 27: + if 0xFF & cv2.waitKey(5) == 27: break diff --git a/samples/python2/feature_homography.py b/samples/python2/feature_homography.py index 469fb10..e1a74a4 100644 --- a/samples/python2/feature_homography.py +++ b/samples/python2/feature_homography.py @@ -85,7 +85,7 @@ if __name__ == '__main__': draw_str(vis, (20, 40), 'matched: %d ( %d outliers )' % (match_n, match_n-inlier_n)) cv2.imshow('img', vis) - ch = cv2.waitKey(1) + ch = 0xFF & cv2.waitKey(1) if ch == ord(' '): matcher.clear() matcher.add([desc]) diff --git a/samples/python2/find_obj.py b/samples/python2/find_obj.py index c5c88db..e34dbcc 100644 --- a/samples/python2/find_obj.py +++ b/samples/python2/find_obj.py @@ -99,4 +99,4 @@ if __name__ == '__main__': # neighbours, so r_threshold is decreased cv2.imshow('find_obj SURF', vis_brute) cv2.imshow('find_obj SURF flann', vis_flann) - cv2.waitKey() \ No newline at end of file + 0xFF & cv2.waitKey() diff --git a/samples/python2/floodfill.py b/samples/python2/floodfill.py index 3cc6c9d..11c7355 100644 --- a/samples/python2/floodfill.py +++ b/samples/python2/floodfill.py @@ -51,7 +51,7 @@ if __name__ == '__main__': cv2.createTrackbar('hi', 'floodfill', 20, 255, update) while True: - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == 27: break if ch == ord('f'): diff --git a/samples/python2/gaussian_mix.py b/samples/python2/gaussian_mix.py index ffeecc5..e5402aa 100644 --- a/samples/python2/gaussian_mix.py +++ b/samples/python2/gaussian_mix.py @@ -51,6 +51,6 @@ if __name__ == '__main__': draw_gaussain(img, m, cov, (0, 0, 255)) cv2.imshow('gaussian mixture', img) - ch = cv2.waitKey(0) + ch = 0xFF & cv2.waitKey(0) if ch == 27: break diff --git a/samples/python2/inpaint.py b/samples/python2/inpaint.py index 0ae3854..6a10b96 100644 --- a/samples/python2/inpaint.py +++ b/samples/python2/inpaint.py @@ -22,7 +22,7 @@ if __name__ == '__main__': sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255)) while True: - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == 27: break if ch == ord(' '): diff --git a/samples/python2/lk_homography.py b/samples/python2/lk_homography.py index be138f7..5683c98 100644 --- a/samples/python2/lk_homography.py +++ b/samples/python2/lk_homography.py @@ -85,7 +85,7 @@ class App: cv2.imshow('lk_homography', vis) - ch = cv2.waitKey(1) + ch = 0xFF & cv2.waitKey(1) if ch == 27: break if ch == ord(' '): diff --git a/samples/python2/lk_track.py b/samples/python2/lk_track.py index 0cbd52e..c967245 100644 --- a/samples/python2/lk_track.py +++ b/samples/python2/lk_track.py @@ -81,7 +81,7 @@ class App: self.prev_gray = frame_gray cv2.imshow('lk_track', vis) - ch = cv2.waitKey(1) + ch = 0xFF & cv2.waitKey(1) if ch == 27: break diff --git a/samples/python2/morphology.py b/samples/python2/morphology.py index 5192ba4..c104f8c 100644 --- a/samples/python2/morphology.py +++ b/samples/python2/morphology.py @@ -48,7 +48,7 @@ if __name__ == '__main__': print " 2 - change structure element shape" print while True: - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == 27: break if ch == ord('1'): diff --git a/samples/python2/motempl.py b/samples/python2/motempl.py index 882649f..b2df02e 100644 --- a/samples/python2/motempl.py +++ b/samples/python2/motempl.py @@ -76,5 +76,5 @@ if __name__ == '__main__': cv2.imshow('motempl', vis) prev_frame = frame.copy() - if cv2.waitKey(5) == 27: - break \ No newline at end of file + if 0xFF & cv2.waitKey(5) == 27: + break diff --git a/samples/python2/mser.py b/samples/python2/mser.py index dcdebc6..b86ff52 100644 --- a/samples/python2/mser.py +++ b/samples/python2/mser.py @@ -33,5 +33,5 @@ if __name__ == '__main__': cv2.polylines(vis, hulls, 1, (0, 255, 0)) cv2.imshow('img', vis) - if cv2.waitKey(5) == 27: - break \ No newline at end of file + if 0xFF & cv2.waitKey(5) == 27: + break diff --git a/samples/python2/opt_flow.py b/samples/python2/opt_flow.py index 8bc9377..98f6ff9 100644 --- a/samples/python2/opt_flow.py +++ b/samples/python2/opt_flow.py @@ -69,7 +69,7 @@ if __name__ == '__main__': cur_glitch = warp_flow(cur_glitch, flow) cv2.imshow('glitch', cur_glitch) - ch = cv2.waitKey(5) + ch = 0xFF & cv2.waitKey(5) if ch == 27: break if ch == ord('1'): diff --git a/samples/python2/peopledetect.py b/samples/python2/peopledetect.py index 27b24fb..f4b876e 100644 --- a/samples/python2/peopledetect.py +++ b/samples/python2/peopledetect.py @@ -50,6 +50,6 @@ if __name__ == '__main__': draw_detections(img, found_filtered, 3) print '%d (%d) found' % (len(found_filtered), len(found)) cv2.imshow('img', img) - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == 27: break diff --git a/samples/python2/squares.py b/samples/python2/squares.py index 2194a72..4099b07 100644 --- a/samples/python2/squares.py +++ b/samples/python2/squares.py @@ -34,6 +34,6 @@ if __name__ == '__main__': squares = find_squares(img) cv2.drawContours( img, squares, -1, (0, 255, 0), 3 ) cv2.imshow('squares', img) - ch = cv2.waitKey() + ch = 0xFF & cv2.waitKey() if ch == 27: - break \ No newline at end of file + break diff --git a/samples/python2/turing.py b/samples/python2/turing.py index f3fea97..ad77002 100644 --- a/samples/python2/turing.py +++ b/samples/python2/turing.py @@ -60,5 +60,5 @@ if __name__ == '__main__': vis = a.copy() draw_str(vis, (20, 20), 'frame %d' % frame_i) cv2.imshow('a', vis) - if cv2.waitKey(5) == 27: + if 0xFF & cv2.waitKey(5) == 27: break diff --git a/samples/python2/video.py b/samples/python2/video.py index d03cdbd..21623b3 100644 --- a/samples/python2/video.py +++ b/samples/python2/video.py @@ -156,7 +156,7 @@ if __name__ == '__main__': ret, img = cap.read() imgs.append(img) cv2.imshow('capture %d' % i, img) - ch = cv2.waitKey(1) + ch = 0xFF & cv2.waitKey(1) if ch == 27: break if ch == ord(' '): diff --git a/samples/python2/watershed.py b/samples/python2/watershed.py index cb0cb8d..8faeb04 100644 --- a/samples/python2/watershed.py +++ b/samples/python2/watershed.py @@ -37,7 +37,7 @@ class App: def run(self): while True: - ch = cv2.waitKey(50) + ch = 0xFF & cv2.waitKey(50) if ch == 27: break if ch >= ord('1') and ch <= ord('7'): -- 2.7.4