How to do it

You need to complete the following steps:

  1. Import the necessary modules:
import cv2import numpy as np
  1. Load the left/right image point correspondences and the individual camera calibration parameters:
data = np.load('../data/stereo/case1/stereo.npy').item()Kl, Kr, Dl, Dr, left_pts, right_pts, E_from_stereo, F_from_stereo = \    data['Kl'], data['Kr'], data['Dl'], data['Dr'], \    data['left_pts'], data['right_pts'], data['E'], data['F']
  1. Stack the left and right point lists into arrays:
left_pts = np.vstack(left_pts)right_pts = np.vstack(right_pts)
  1. Get rid of lens distortions:
left_pts = cv2.undistortPoints(left_pts, Kl, Dl, P=Kl)right_pts = cv2.undistortPoints(right_pts, Kr, Dr, P=Kr)
  1. Estimate the fundamental matrix:
F, mask ...

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.