# How to get the projection matrix from odometry/tf data?

I would like to compare my results of visual Odometry with the groundtruth provided by the KITTI dataset. For each frame in the groundthruth, i have a projection matrix. For example:

1.000000e+00 9.043683e-12 2.326809e-11 1.110223e-16 9.043683e-12 1.000000e+00 2.392370e-10 2.220446e-16 2.326810e-11 2.392370e-10 9.999999e-01 -2.220446e-16


Here the instructions provided by the readme:

Row i represents the i'th pose of the left camera coordinate system (i.e., z pointing forwards) via a 3x4 transformation matrix. The matrices are stored in row aligned order (the first entries correspond to the first row), and take a point in the i'th coordinate system and project it into the first (=0th) coordinate system. Hence, the translational part (3x1 vector of column 4) corresponds to the pose of the left camera coordinate system in the i'th frame with respect to the first (=0th) frame

But I don't know how to produce the same kind of data for me. What I have for each frame in my case:

• The Tf transformation from the init_camera (the fix one from the (0,0,0)) to the left camera which is moving. So I have the translation vector and the quaternion rotation.
• The odometry data: the pose and the twist
• Camera calibration parameters

With those data, How I compare with the groundtruth ? So I need to find the projection matrix from the data above but don't know how to do it.

Can someone help me ?

Thank

• I do not understand your question. Seems like you are trying to compare your own odometry algorithm with something - but with what? You could compare it for instance to KITTI GPS data (which can be considered as an odometry ground-truth probably) to see how your odometry performs. Seems to me that you are trying to compare your odometry algorithm to the LIBVISO2 output over the same input data (mono/stereo sequence), which you of course can do too... it really depends on what you need to do. Apr 20 '15 at 10:10
• PS. The projection matrix is the result of LIBVISO library - you need to feed the library with image data and it will output the matrix. In the matrix the last column are the x,y,z deltas to the previous frame (if I recall correctly). Apr 20 '15 at 10:13
• Thank for your answer. Actually no I don't want to compare LIBVISO but this one: [link](cvlibs.net/datasets/kitti/… ) to the ground truth provided by the KITTI Benchmark but the problem is in their groundtruth I have for each frame the projection matrix of the camera (3x4) but me, as an result of the algorithm I test, I can only have what I said above...That's the main difficulty for me. Apr 21 '15 at 0:54

## 1 Answer

I'm not sure what reference frame the KITTI ground truth data is in, but I'm going to guess the robot frame. The ground truth data looks to just be a transformation matrix for a homogenous point. The transform is represented in the form such that P' = T * P where P' is a point in the world coordinate frame, T is the "projection" matrix (I'm not sure, but I don't think this is the right term for this matrix), and P is the point in the robot coordinate frame. Here the points are represented as [x,y,z,1]^T. The transformation has the form [R t; 0 1] where R is the rotation of the robot and t is the translation of the robot. The [0 1] row has been elided in the KITTI data. To convert this transform to translation + quaternion form, the translation is just the rightmost column. The quaternion can be found by converting the rotation matrix R to a quaternion. See http://en.wikipedia.org/wiki/Rotation_matrix#Quaternion for formulas for this conversion.

The ground truth data is probably in the robot reference frame. To convert it to the camera reference frame, you'll need to use the camera extrinsics. If the camera extrinsics which maps points from robot space to camera space is E, then the ground truth in the camera frame is E * T * E^(-1) where T is the ground truth in the robot frame. This is just composing the transforms (robot->camera) o (robot->robot) o (camera->robot). If the extrinsics is given as the transform from camera space to robot space, then the inverse will be on the left side instead.

• Thank you so much for your answer. So okey if I got it well, I have to take the right most column to have the translation and convert the rotation matrix to a quaternion form so that I can convert with my data ? But I'm sorry, I don't understand your last part about the camera reference frame..Because the camera reference frame is the robot, no ? can you try to explain me again ? Thank Apr 30 '15 at 3:55