c++opencvransac

How can I retrieve the points of the homography computed findHomography and RANSAC?


I am new to OpenCV. I noticed that the line

Mat H = findHomography( obj, scene, CV_RANSAC );

helps to find the homography H using RANSAC.

However, I need the locations of the 'purified' matching points after RANSAC and I simply cannot find which function I can use. I need a function that uses RANSAC and returns the matching points' locations after RANSAC.


Solution

  • findHomography can optionally provide the mask of inliers and outliers (inliers are what you call purified matching).

    C++: Mat findHomography(InputArray srcPoints, InputArray dstPoints, int method=0, double ransacReprojThreshold=3, OutputArray mask=noArray() )

    Python: cv2.findHomography(srcPoints, dstPoints[, method[, ransacReprojThreshold[, mask]]]) → retval, mask

    You can use only inliers (i.e. points with corresponding mask value equals to 1) when doing your match.