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++ )
{
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 .