diff python/cvutils.py @ 151:4af774bb186d

wrote a simple script to compute homography from point correspondences and display the reprojection for visual verification
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 06 Sep 2011 17:55:06 -0400
parents 404f3cade05f
children 74b1fc68d4df
line wrap: on
line diff
--- a/python/cvutils.py	Thu Sep 01 18:37:35 2011 -0400
+++ b/python/cvutils.py	Tue Sep 06 17:55:06 2011 -0400
@@ -3,18 +3,27 @@
 
 import Image, ImageDraw # PIL
 try:
-    import cv,cv2
+    import cv2
     opencvExists = True
 except ImportError:
     print('OpenCV library could not be loaded')
     opencvExists = False
 from sys import stdout
 
+import utils
+
 #import aggdraw # agg on top of PIL (antialiased drawing)
 #import utils
 
 __metaclass__ = type
 
+cvRed = (0,0,255)
+cvGreen = (0,255,0)
+cvBlue = (255,0,0)
+cvColors = utils.PlottingPropertyValues([cvRed,
+                                         cvGreen,
+                                         cvBlue])
+
 def drawLines(filename, origins, destinations, w = 1, resultFilename='image.png'):
     '''Draws lines over the image '''
     
@@ -33,10 +42,10 @@
 
 def computeHomography(srcPoints, dstPoints, method=0, ransacReprojThreshold=0.0):
     '''Returns the homography matrix mapping from srcPoints to dstPoints (dimension Nx2)'''
-    cvSrcPoints = arrayToCvMat(srcPoints);
-    cvDstPoints = arrayToCvMat(dstPoints);
-    H = cv.CreateMat(3, 3, cv.CV_64FC1)
-    cv.FindHomography(cvSrcPoints, cvDstPoints, H, method, ransacReprojThreshold)
+    #cvSrcPoints = arrayToCvMat(srcPoints);
+    #cvDstPoints = arrayToCvMat(dstPoints);
+    #H = cv.CreateMat(3, 3, cv.CV_64FC1)
+    H, mask = cv2.findHomography(srcPoints, dstPoints, method, ransacReprojThreshold)
     return H
 
 def cvMatToArray(cvmat):