composeRT input/output question

I have two frame transformations, one from frame 0 to frame 1, and one from frame 1 to frame 2, and I would like to concatenate these into the transformation from frame 0 to frame 2. I'm computing the pose of a moving camera, and the first transformation (0-1) represent the previous pose of the camera (transformation from its initial pose) and the 1-2 transformation is the newest change of pose, represented by tvec and rvec gotten from solvePnPRansac.

However, as I cannot just try out different inputs in my code and see if the output seems correct, since my system currently consists of lots of noise, I would like to have the math check out before I implement it into my application. But while I try to use the formulas given in the documentation with different rvecs and tvecs, I can't get the outputs (rvec3/tvec3) I want. These are the formulas:

I've tried with the following rvecs/tvecs:

• rvec1: Rotation from frame 1 to frame 0
• tvec1: vector from the origin of frame 0 to the origin of frame 1, given in frame 0 coordinates
• rvec2: Rotation from frame 2 to frame 1
• tvec2: vector from the origin of frame 1 to the origin of frame 2, given in frame 1 coordinates

I want to end up with:

• rvec3: Rotation from frame 0 to frame 2 (or inversed, doesn't matter)
• tvec3: vector from frame 0 to frame 2 given in frame 0 coordinates (or negated)

However, with these vectors, I can't get the formula in the documentation to make sense. The rvec3-formula makes sense, and with rvec1/rvec2 I get rvec3=(rvec2*rvec1)⁻¹ to equal the rotation from frame 2 to frame 0. However, the computation of tvec3 doesn't add up:

The formula says tvec3 = rvec2 * tvec1 + tvec2, but rvec2 * tvec1 doesn't make sense with my vectors. I mean, it says to rotate a vector given in frame 0 coordinates from frame 2 to frame 1. A vector given in frame 0 coordinates need to be multiplied with a rotation matrix representing the rotation from frame 0 to some other frame, but this is not the case here. And it haven't made sense with any other vectors I've tried as well, for that matter.

Someone that could help me with these calculcations? Thanks!

edit retag close merge delete

Sort by » oldest newest most voted

The formulas look correct for me. The corresponding equations are given below.

The transformation that allows converting a 3D point expressed in the frame 0 to the frame 1 is:

The transformation that allows converting a 3D point expressed in the frame 1 to the frame 2 is:

The transformation that allows converting a 3D point expressed in the frame 0 to the frame 2 is then:

Note that as rvec is a Rodriges rotation vector, rodrigues(rvec) gives the corresponding rotation matrix R.

more

Thanks! Nice explanation, it makes more sense to me now. However, the rvec3 output from composeRT is the (0,0) element of your T²_0 matrix inversed, is it not?

( 2018-03-08 11:00:09 -0500 )edit

rvec3 is the same thing than 2_R_0 but in Rodrigues rotation vector representation. rvec = rodrigues^-1(R) means just that the rotation matrix is converted into a rotation vector.

( 2018-03-09 10:06:58 -0500 )edit

I see! Thanks!

( 2018-03-20 07:48:20 -0500 )edit