diff python/cvutils.py @ 639:4e7925cb4f8f

modified tsai camera homography computation to avoid using os dependent temporary files
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Thu, 09 Apr 2015 13:11:25 +0200
parents 852f5de42d01
children 51269511229b
line wrap: on
line diff
--- a/python/cvutils.py	Wed Apr 08 16:07:15 2015 +0200
+++ b/python/cvutils.py	Thu Apr 09 13:11:25 2015 +0200
@@ -277,12 +277,11 @@
         else:
             print 'Cannot load file ' + videoFilename
 
-    def computeHomographyFromPDTV(cameraFilename):
-        '''Returns the homography matrix at ground level from PDTV format
+    def computeHomographyFromPDTV(camera):
+        '''Returns the homography matrix at ground level from PDTV camera
         https://bitbucket.org/hakanardo/pdtv'''
-        import pdtv
         from numpy import array
-        camera = pdtv.load(cameraFilename)
+        # camera = pdtv.load(cameraFilename)
         srcPoints = [[x,y] for x, y in zip([1.,2.,2.,1.],[1.,1.,2.,2.])] # need floats!!
         dstPoints = []
         for srcPoint in srcPoints:
@@ -423,6 +422,7 @@
         raise Exception('points of dimension {0} {1}'.format(points.shape[0], points.shape[1]))
 
     if (homography is not None) and homography.size>0:
+        #alternatively, on could use cv2.convertpointstohomogeneous and other conversion to/from homogeneous coordinates
         augmentedPoints = append(points,[[1]*points.shape[1]], 0)
         prod = dot(homography, augmentedPoints)
         return prod[0:2]/prod[2]