diff python/calibration-translation.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 b0719b3ad3db
children
line wrap: on
line diff
--- a/python/calibration-translation.py	Mon Mar 18 23:37:45 2013 -0400
+++ b/python/calibration-translation.py	Thu Mar 21 14:01:46 2013 -0400
@@ -58,7 +58,7 @@
     frameFilename = utils.removeExtension(f)+'-frame.png' # TODO if frame image already exists, no need to search for it again
     if not os.path.exists(frameFilename):
         key = -1
-        while key != cvutils.cvKeyNumbers['y']:
+        while chr(key&255) != 'y':
             (ret, img) = captures[f].read()
             cv2.imshow('Image',img)
             print('Can one see the reference points in the image? (y/n)')
@@ -91,15 +91,15 @@
             cv2.circle(displayImg, tuple(p+t[0]), 3, (255,0,0))
         cv2.imshow('Image',displayImg)
 
-        while not(key == cvutils.cvKeyNumbers['y'] or key == cvutils.cvKeyNumbers['n']):
+        while not(chr(key&255) == 'y' or chr(key&255) == 'n'):
             print('Are the translated points rightly located (y/n)?')
             key = cv2.waitKey(0)
-        if key == cvutils.cvKeyNumbers['y']: # compute homography with translated numbers
+        if chr(key&255) == 'y': # compute homography with translated numbers
             newImgPts = np.array([p+t[0] for p in imgPts])
     else:
         print('No translation could be found automatically. You will have to manually input world reference points.')
 
-    if t==None or key != cvutils.cvKeyNumbers['y']:# if no translation could computed or it is not satisfactory
+    if t==None or chr(key&255) != 'y':# if no translation could computed or it is not satisfactory
         print('Select the corresponding points in the same order as in the reference image')
         plt.figure(1)
         plt.imshow(displayRef)