如何使用OpenCV计算2帧之间的旋转平移矩阵

时间:2013-11-28 23:14:38

标签: c++ opencv

我想用OpenCV计算2帧之间的旋转平移矩阵[R | t]矩阵(参见http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html?highlight=fundamentalmat#camera-calibration-and-3d-reconstruction

我知道我必须:

1)检测两个帧上的特征(例如,SURF),
2)Matche功能(例如ORBBFMatcher),
3)计算[R | t]矩阵。内在参数是已知的。

但是,我不知道如何使用OpenCV完成第三步。有没有常规/简单的方法来做到这一点?

我的目标是计算相机的轨迹。

2 个答案:

答案 0 :(得分:1)

您需要使用RANSAC来计算Fundamental或Essential矩阵

OpenCV很好地提供了cv::findFundamentalMat功能。

然后从[R|t]获取A,内在参数矩阵和基本矩阵F。我会将您推荐给Extract Translation and Rotation from Fundamental Matrix以获取更多相关信息。

答案 1 :(得分:1)

你可以简单地使用stereoCalibrate旋转和旋转。翻译矩阵是R&分别为T. object_points,l_image_points,r_image_points对象和左/右图像帧中匹配点/要素的坐标。 stereoCalibrate(object_points,l_image_points,r_image_points,LcameraMatrix,LdistCoeffs,RcameraMatrix,RdistCoeffs,imageSize,R,T,E,F);