Special case 2-view geometry - estimating homography transformation
In case you need to project points from one plane to another, it's possible to do by applying a homography matrix. This matrix allows you to project a point from one plane to another if you know the corresponding transformation for the planes. OpenCV has a functionality to find the homography matrix, and this recipe shows you how to use and apply it.
Getting ready
Before you proceed with this recipe, you need to install the OpenCV version 3.3 (or greater) Python API package.
How to do it
You need to complete the following steps:
- Import the necessary modules:
import cv2 import numpy as np
- Load the camera matrix, the distortion coefficients, and two frames taken by the camera:
camera_matrix = np.load('../data/pinhole_calib/camera_mat.npy') dist_coefs = np.load('../data/pinhole_calib/dist_coefs.npy') img_0 = cv2.imread('../data/pinhole_calib/img_00.png') img_1 = cv2.imread('../data/pinhole_calib/img_10.png')
- Undistort the frames:
img_0...