Figure to understand reference directions

958 views
Skip to first unread message

m. fatih aydogdu

unread,
Jul 26, 2022, 7:47:22 AM7/26/22
to COLMAP
Hello

In the explanations about output format, it is written that 

"The local camera coordinate system of an image is defined in a way that the X axis points to the right, the Y axis to the bottom, and the Z axis to the front as seen from the image."

Is there any figure explaining the axis directions in order to help understand translations and rotations easily?


Wayne Cochran

unread,
Jul 26, 2022, 11:34:08 AM7/26/22
to COLMAP
colmap uses the same convention as OpenCV so you can look at their figures and docs...

https://stackoverflow.com/questions/17987465/how-is-the-camera-coordinate-system-in-opencv-oriented

mfatih...@gmail.com

unread,
Jul 26, 2022, 1:04:40 PM7/26/22
to COLMAP
Hello and thank you for the answer

I am trying to understand the z distance of the 2 figures in the attachment.

The distance between the camera and the building in 05466646_5360480312.jpg is bigger than the same distance in 06857713_2570944910.jpg.

When I get the distance of images via tvec attribute in COLMAP, for 05466646_5360480312 I have 15.8588 and for 06857713_2570944910 I have 0.286698.

When I look at the OpenCV figures you mentioned the direction of the z-axis is not consistent with the values I get via tvec attribute.

Maybe if I get -15.8588 for 05466646_5360480312 and - 0.286698 for 06857713_2570944910 it can be consistent.

While interpreting the translation and rotation angles obtained from COLMAP I am making some mistakes.

__
thank you for your answer
06857713_2570944910.jpg
05466646_5360480312.jpg

Wayne Cochran

unread,
Jul 26, 2022, 2:51:09 PM7/26/22
to COLMAP
The tvec vector stored the translation (after rotation)  i.e., does not store the position of the camera.
To get the camera position C = - tvec.transpose() * rotation .

       Eigen::Matrix3d R = img.QVec().normalized().toRotationMatrix();
       Eigen::Vector3d pos = -R.transpose() *  image.Qvec();

Wayne Cochran

unread,
Jul 26, 2022, 4:28:00 PM7/26/22
to COLMAP
Well I can't see to edit my buggy response -- just note that camera_pos = - Rotation.transpose() * tvec

mfatih...@gmail.com

unread,
Aug 12, 2022, 10:22:28 AM8/12/22
to COLMAP
Hello

Thanks for the previous answers
I was referencing the scripts here while doing my calculations with COLMAP.

Can you confirm the statements below?

In COLMAP, each dataset has a world coordinate system and world origin.
Axis directions of the coordinate systems are the same as open CV.
All the 3D feature positions, camera positions, and rotations are defined with respect to the world coordinate system.

In order to get a camera rotation with respect to the world coordinate system, one can use qvec variable of COLMAP images.
R = qvec2rotmat(q) will give rotations of each camera with respect to the world coordinate system.

In order to get a camera translation with respect to the world coordinate system, one can use  tvec  variable of COLMAP images.
tvec does not give directly the camera translation with respect to the world coordinate system
Instead, one needs to compute C = - tvec.transpose() * rotation in order to get camera translation with respect to world coordinate system.

__
best regards

mfatih...@gmail.com

unread,
Aug 13, 2022, 9:51:21 AM8/13/22
to COLMAP
Hello

Thanks for the previous answers
I was referencing the scripts here while doing my calculations with COLMAP.

Can you confirm the corrected statements below?

In COLMAP, each dataset has a world coordinate system and world origin.
Axis directions of the coordinate systems are the same as open CV.
All the 3D feature positions, camera positions, and rotations are defined with respect to the world coordinate system.

In order to get a camera rotation with respect to the world coordinate system, one can use qvec variable of COLMAP images.
R = qvec2rotmat(q) will give rotations of each camera with respect to the world coordinate system.

In order to get a camera translation with respect to the world coordinate system, one can use  tvec  variable of COLMAP images.
tvec does not give directly the camera translation with respect to the world coordinate system
Instead, one needs to compute C =  - Rotation.transpose() * tvec   in order to get camera translation with respect to world coordinate system.

__
best regards

Wayne Cochran

unread,
Aug 13, 2022, 12:12:45 PM8/13/22
to COLMAP
I fixed my buggy answer in previous post, the correct camera position formula is
C = - R.transpose() * tvec

If you are using row vectors
C.transpose() = -tvec.transpose() * R

COLMAP does indeed use its own world coordinate system which is normalized so the coordinate values range from -10 to +10. 
COLMAP does indeed use the same view convention as OpenCV where the viewer is looking out the positive z-axis, y-axis down, and
x-axis to the right. 

mfatih...@gmail.com

unread,
Aug 13, 2022, 2:45:29 PM8/13/22
to COLMAP
Thank you very much for the answer

When I use  C = - R.transpose() * tvec  for translation calculations in python, the normalized translation values calculated in x,y and z directions are consistent with what I observe by looking at the images.

I also use R values to calculate euler angles.
Then I convert the euler angles to degrees.
I check the calculated pitch, yaw and roll angles with images visually.
I observe that the magnitudes of the angles are consistent with images.
I am not sure about the sign of the angles.

Does the rotation values in COLMAP dateset give the rotation of camera cordinates with respect to world coordinates?
Or does it give world coordinates with respect to camera coordinates?

When I look at the sign of the angles calculated I I observev the second case.
When I transpose the rotation matrix I observe the first case.

By right hand rule and the world coordinate system shown I think the first case is the right one.
__
best regards

Wayne Cochran

unread,
Aug 14, 2022, 5:28:10 PM8/14/22
to COLMAP
The rotation and translation transform points from world coordinates to camera/view coordinates.

mfatih...@gmail.com

unread,
Aug 15, 2022, 9:55:23 AM8/15/22
to COLMAP
Thank you very much for the answer

When I look at the calculated z positions of some images I see values like -024.1073, -013.4155, -013.2501 and -013.2224.
This is out of the normalization ranges (+10, -10). Is it normal?

Wayne Cochran

unread,
Aug 15, 2022, 3:16:03 PM8/15/22
to COLMAP
Are you sure those are the positions of images and not the translations?
Are you performing Bundle Adjustment?  
This is the routine in reconstruction.cc:

(BTW, this wed editor makes it impossible to insert formatted code that looks decent)

  // Normalize scene by scaling and translation to avoid degenerate                                                           

  // visualization after bundle adjustment and to improve numerical                                                           

  // stability of algorithms.                                                                                                 

  //                                                                                                                          

  // Translates scene such that the mean of the camera centers or point                                                       

  // locations are at the origin of the coordinate system.                                                                    

  //                                                                                                                          

  // Scales scene such that the minimum and maximum camera centers are at the                                                 

  // given `extent`, whereas `p0` and `p1` determine the minimum and                                                          

  // maximum percentiles of the camera centers considered.                                                                    

  void Normalize(const double extent = 10.0, const double p0 = 0.1,

                 const double p1 = 0.9, const bool use_images = true);

fatih

unread,
Aug 19, 2022, 2:25:50 PM8/19/22
to col...@googlegroups.com
Hello and thank you for the answer.

I am not using bundle adjustment.
I am just trying to calculate Rotation and Translation angles between image pairs to use as ground truth for our framework.

I think I have no problem with rotation angles.
But I have calculation problems for translation angles.

Let's say that R2_1 is a rotation matrix that transforms points in image 2 reference coordinates to points in image 1 reference coordinates. 
I calculate it as

R2_1 = np.matmul( np.transpose(gt_rotations[int(im2_no)]), gt_rotations[int(im1_no)] )

Then I get tvecs for image 1 and image 2 as

tvec1 = gt_translations[int(im1_no)]
tvec2 = gt_translations[int(im2_no)]

Then I carry tvec2 to image 1 coordinates as

 T1_of_tvec2 = np.matmul( R2_1, -tvec2 )

Finally, I add 2 vectors in image 1 coordinates to calculate the translation between image 1 and image 2 as

T_Groun_truth = np.add( tvec1, T1_of_tvec2)

But it does not give meaningful values. Could you see my error in the calculations?

best regards


--
You received this message because you are subscribed to a topic in the Google Groups "COLMAP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/colmap/PL0HUx372-U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to colmap+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/colmap/6cb63a58-b438-475b-bcb8-7f2055758c9cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages