Essential matrix decomposition into rotation and translation
In this recipe, you will learn how to decompose essential matrices into two hypotheses about the relative rotation and translation vectors between two cameras in a stereo rig. This functionality is used when estimating stereo rig parameters.
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 precomputed essential matrix:
data = np.load('../data/stereo/case1/stereo.npy').item() E = data['E']
- Decompose the essential matrix into two possible rotations and translations:
R1, R2, T = cv2.decomposeEssentialMat(E)
- Print the results:
print('Rotation 1:') print(R1) print('Rotation 2:') print(R2) print('Translation:') print(T)
How it works
We use the OpenCV cv2.decomposeEssentialMat
function, which takes an essential matrix as input and returns two candidates...