How it works...

In this recipe, we estimate homography model parameters between two images using the robust RANSAC algorithm. It's done through the cv2.findHomography function with the cv2.RANSAC parameter. The function returns a homography transformation estimated by point correspondences as well as the inliers mask. The inlier mask deals with correspondences that satisfy the estimated motion model with a low enough error. In our case, the error is computed as a Euclidean distance between the matched point and the corresponding point transformed according to the motion model.

The following is the expected output:

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.