DouglasAdams
DouglasAdams

Reputation: 490

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

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.

Upvotes: 4

Views: 5611

Answers (2)

Basel
Basel

Reputation: 151

You can simply use stereoCalibrate where your rotation & translation matrices are R & T respectively. object_points, l_image_points, r_image_points coordinates of matched points/features in object and left/right image frames. stereoCalibrate(object_points, l_image_points, r_image_points, LcameraMatrix, LdistCoeffs, RcameraMatrix, RdistCoeffs, imageSize, R, T, E, F);

Upvotes: 1

Olotiar
Olotiar

Reputation: 3274

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.

Upvotes: 2

Related Questions