Tongxin Wang
Tongxin Wang

Reputation: 33

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.

Upvotes: 1

Views: 7800

Answers (2)

user9775723
user9775723

Reputation: 1

when you get truly result of H33 from finghomography, why not perspectiveTransform the match points from mask to frame, then you get many 'purified' matching points.

Upvotes: 0

Miki
Miki

Reputation: 41765

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.

Upvotes: 1

Related Questions