Mercurial Hosting > traffic-intelligence
changeset 469:7d2310f64511
merge done
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 06 Mar 2014 15:01:33 -0500 |
parents | 5304299e53a5 (diff) 08b67c9baca2 (current diff) |
children | a8f95bbd79bc |
files | |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Wed Mar 05 23:01:00 2014 -0500 +++ b/python/cvutils.py Thu Mar 06 15:01:33 2014 -0500 @@ -265,6 +265,21 @@ H, mask = cv2.findHomography(array(srcPoints), array(dstPoints), method, ransacReprojThreshold) return H + def correctedCoordinates(x,y, map1, map2): + '''Returns the coordinates of a point in undistorted image + map1 and map2 are the mapping functions from undistorted image + to distorted (original image) + map1(x,y) = originalx, originaly''' + from numpy import abs, logical_and, unravel_index, dot, sum + from matplotlib.mlab import find + distx = abs(map1-x) + disty = abs(map2-y) + indices = logical_and(distx<1, disty<1) + closeCoordinates = unravel_index(find(indices), distx.shape) # returns i,j, ie y,x + xWeights = 1-distx[indices] + yWeights = 1-disty[indices] + return dot(xWeights, closeCoordinates[1])/sum(xWeights), dot(yWeights, closeCoordinates[0])/sum(yWeights) + def printCvMat(cvmat, out = stdout): '''Prints the cvmat to out'''