diff python/cvutils.py @ 303:514f6b98cd8c

fixed bug with keys from waitKey on Ubuntu 12.10
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 21 Mar 2013 14:01:46 -0400
parents 9d88a4d97473
children ca9131968bce
line wrap: on
line diff
--- a/python/cvutils.py	Mon Mar 18 23:37:45 2013 -0400
+++ b/python/cvutils.py	Thu Mar 21 14:01:46 2013 -0400
@@ -24,10 +24,6 @@
                                          cvGreen,
                                          cvBlue])
 
-cvKeyNumbers = {'a':1048673,
-                'n': 1048686,
-                'y': 1048697}
-
 def drawLines(filename, origins, destinations, w = 1, resultFilename='image.png'):
     '''Draws lines over the image '''
     
@@ -97,7 +93,7 @@
             ret = True
             frameNum = firstFrameNum
             capture.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, firstFrameNum)
-            while ret and key!= 113: # 'q'
+            while ret and chr(key&255)!= 'q':
                 ret, img = capture.read()
                 if ret:
                     print('frame {0}'.format(frameNum))
@@ -139,7 +135,7 @@
                 lastFrameNum = maxint
             else:
                 lastFrameNum = lastFrameNumArg
-            while ret and key!= 113 and frameNum < lastFrameNum: # 'q'
+            while ret and chr(key&255)!= 'q' and chr(key&255)!= 'Q' and frameNum < lastFrameNum:
                 ret, img = capture.read()
                 if ret:
                     print('frame {0}'.format(frameNum))
@@ -154,7 +150,7 @@
                             cv2.putText(img, '{0}'.format(obj.num), obj.projectedPositions[frameNum-obj.getFirstInstant()].asint().astuple(), cv2.FONT_HERSHEY_PLAIN, 1, cvRed)
                     cv2.imshow('frame', img)
                     key = cv2.waitKey()
-                    if key == 115:
+                    if chr(key&255) == 's':
                         cv2.imwrite('image.png', img)
                     frameNum += 1