diff python/cvutils.py @ 160:b0719b3ad3db

created function to load point correspondences and updates scripts that use it
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 19 Sep 2011 16:43:28 -0400
parents 115f7f90286d
children 8e7b354666ec
line wrap: on
line diff
--- a/python/cvutils.py	Mon Sep 12 16:38:47 2011 -0400
+++ b/python/cvutils.py	Mon Sep 19 16:43:28 2011 -0400
@@ -52,6 +52,13 @@
     points = loadtxt(filename, delimiter=',')
     savetxt(utils.removeExtension(filename)+'-point-correspondences.txt',append(points[:,:2].T, points[:,3:].T, axis=0))
 
+def loadPointCorrespondences(filename):
+    '''Loads and returns the corresponding points in world (first 2 lines) and image spaces (last 2 lines)'''
+    from numpy.lib.io import loadtxt
+    from numpy import float32
+    points = loadtxt(filename, dtype=float32)
+    return  (points[:2,:].T, points[2:,:].T) # (world points, image points)
+
 def computeHomography(srcPoints, dstPoints, method=0, ransacReprojThreshold=0.0):
     '''Returns the homography matrix mapping from srcPoints to dstPoints (dimension Nx2)'''
     #cvSrcPoints = arrayToCvMat(srcPoints);