How to compute rotation-translation matrix between 2 frames with OpenCV

c++, opencv

Solution

You will need to use RANSAC to compute either the Fundamental or Essential matrices

OpenCV nicely provides the `cv::findFundamentalMat` function to do so.

Then it is a matter of getting `[R|t]` from both `A`, the intrinsic parameter matrix and `F`, the fundamental matrix. I would refer you to Extract Translation and Rotation from Fundamental Matrix for more information on that.

Problem

I want to compute the rotation-translation matrix [R|t] matrix between 2 frames with `OpenCV` (see http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=fundamentalmat#camera-calibration-and-3d-reconstruction) I know I have to : 1) Detect features on both frames (with `SURF`, for example), 2) Matche features (with `ORB` and `BFMatcher`, for example), 3) Compute the [R|t] matrix. The intrinsic parameters are known. However, I don't know how to complete the third step with `OpenCV`. Is there a regular/easy way to do this ? My aim is to compute the trajectory of a camera.

Original source