Mercurial Hosting > traffic-intelligence
comparison 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 |
comparison
equal
deleted
inserted
replaced
159:115f7f90286d | 160:b0719b3ad3db |
---|---|
49 by the matlab camera calibration tool''' | 49 by the matlab camera calibration tool''' |
50 from numpy.lib.io import loadtxt, savetxt | 50 from numpy.lib.io import loadtxt, savetxt |
51 from numpy.lib.function_base import append | 51 from numpy.lib.function_base import append |
52 points = loadtxt(filename, delimiter=',') | 52 points = loadtxt(filename, delimiter=',') |
53 savetxt(utils.removeExtension(filename)+'-point-correspondences.txt',append(points[:,:2].T, points[:,3:].T, axis=0)) | 53 savetxt(utils.removeExtension(filename)+'-point-correspondences.txt',append(points[:,:2].T, points[:,3:].T, axis=0)) |
54 | |
55 def loadPointCorrespondences(filename): | |
56 '''Loads and returns the corresponding points in world (first 2 lines) and image spaces (last 2 lines)''' | |
57 from numpy.lib.io import loadtxt | |
58 from numpy import float32 | |
59 points = loadtxt(filename, dtype=float32) | |
60 return (points[:2,:].T, points[2:,:].T) # (world points, image points) | |
54 | 61 |
55 def computeHomography(srcPoints, dstPoints, method=0, ransacReprojThreshold=0.0): | 62 def computeHomography(srcPoints, dstPoints, method=0, ransacReprojThreshold=0.0): |
56 '''Returns the homography matrix mapping from srcPoints to dstPoints (dimension Nx2)''' | 63 '''Returns the homography matrix mapping from srcPoints to dstPoints (dimension Nx2)''' |
57 #cvSrcPoints = arrayToCvMat(srcPoints); | 64 #cvSrcPoints = arrayToCvMat(srcPoints); |
58 #cvDstPoints = arrayToCvMat(dstPoints); | 65 #cvDstPoints = arrayToCvMat(dstPoints); |