how to get the relative camera pose to another camera pose?

47 views (last 30 days)
Two camera absolute poses, pose1(rotationMatrix1,translationVec1),pose2(rotationMatrix2,translationVec2) are know,how to get the camera2 to camera1 relative pose? i know cam2 to cam1 relative oriention matrix is R2*R1',but i can't be sure the relative translation, is (T2-T1)*R1' or T2-T1*R1'? (rotationMatrix1=R1, rotaitonMartix=R2,translationVec1=T1,translationVec2=T2)
i can see many of vSLAM examples "helperAddNewKeyFrame" function use (T2-T1)*R1' as relative translation vectors? i think is T2-T1*R1',because T21 = T2w+Tw1 = T2+(0-T1)*R1' = T2-T1*R1'
It is good to hear that since R2022b, the computer vision toolbox and image process toolbox have started to support the use of the pre-multiply convention as a priority

Accepted Answer

Qu Cao
Qu Cao on 16 May 2022
Edited: Qu Cao on 17 May 2022
Note that the geometric transformation convention used in the Computer Vision Toolbox (CVT) is different from the one used in the Robotics System Toolbox. If you transform a 3-D point [X, Y, Z] from one coordinate system to another, its new location is computed as
[X2, Y2, Z2] = [X, Y, Z] * R_cvt + t_cvt
where R_cvt is the rotation matrix and t_cvt is the translation vector. This is diffrent from the common convention you may have seen:
[X2, Y2, Z2]^T = R * [X, Y, Z]^T + t
where T represents transpose.
In other words, CVT uses the post-multiply convention and the rotation matrix and the translation vector are the transposed version of the common format.
Back to the question you were asking, following the common convention, the relative pose is computed as:
R_rel = R1^T * R2
t_rel = R1^T * (t2 - t1)
See also this post for reference.
Now with the new convention,
R_rel_cvt = R_rel^T = R2^T * R1 = R2_cvt * R1_cvt^T
t_rel_cvt = (t2-t1)^T * R1 = (t2_cvt - t1_cvt) * R1_cvt^T
this explains the code in the helperAddNewKeyFrame function.
I know this is a little confusing, but we're actively working on adopting the common geometric transformation convention in the Computer Vision Toolbox.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!