perspectiveTransform a set of points

asked 2013-12-04 16:29:15 -0500

Raul Andrew gravatar image

Hello! I have two images, the first is distorted under perspective and the second is the rectification of a square in the previous image, obtained transforming it with the warpPerspective() function and a given 3x3 trasformation matrix M.

After working with the rectified image I've obtained a set of points that I'd like to transform back to the original image. These points are stored as Point2f or Point3f if I convert them to homogeneous coordinates. To my knowledge Opencv doesn't provide a function to directly transform a point or a set of points with a transformation matrix.

Do you have any suggestions on how I could do it? I saw similar questions and I found solutions like

std::vector<cv::point> inPts, outPts; inpPts.push_back(cv::Point(3, 5)); perspectiveTransform(inPts, outPts, homography);

but it doesn't seem to work. I was thinking of using M.inv() to map back the points in the first image, is that correct?

Thank you in advance.


edit retag flag offensive close merge delete