How to apply RANSAC results for SURF, SIFT and ORB

I am working on image processing. I want to map 2D functions, and I did a lot of tests on SURF, SIFT, ORB.
How can I apply RANSAC to SURF / SIFT / ORB in OpenCV?

+5
source share
1 answer

OpenCV has a function cv::findHomographythat RANSAC can use to find a homography matrix related to two images. You can see an example of this function in action here .

In particular, the section of code that interests you:

FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );

for( int i = 0; i < good_matches.size(); i++ )
{
    //-- Get the keypoints from the good matches
    obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
    scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
}

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

Then you can use the function cv::perspectiveTransformto deform the images according to the homography matrix.

cv::findHomography, CV_RANSAC, 0, CV_LMEDS, . OpenCV .

+23

All Articles