How to get the camera rotation? (Aruco Library)

我是研究僧i 提交于 2021-02-05 10:41:10

问题


I've been trying to understand the output of the aruco_test.cpp program that is included when you download the Aruco Library.

The output has this format:

22=(236.87,86.4296) (422.581,78.3856) (418.21,228.032) (261.347,228.529) Txyz=0.00813142 -0.0148134 0.140595 Rxyz=-2.14032 0.0777095 0.138929

22 is the unique identifier of the marker, the next four pairs of numbers are the four corners of the marker. My problem here is the two vectors Tvec and Rvec.

I've been reading on the Internet that tvec is the translation vector from my camera's center to my object (the marker in this case) and that rvec is the rotation of the object with respect to my camera.

I've got a few questions regarding this:

How can I know the axis of my camera? I mean, is there a way to know where the x, y and z are facing?

How can I get the rotation of the camera from the rotation of the object wrt the camera?

Can someone explain me the meaning of the vectors better so I can really understand it? I think my main problem here is that I don't really know what those numbers mean for real.

EDIT: I've been doing some testing to check how the rotation works and I don't really understand the results:

  1. Moving the camera, marker fixed on the floor:

Initial position: camera looking at the marker - 'z' axis of the marker looking to the camera, 'y' is going upwards and 'x' goes to the right: Rxyz=2.40804 -0.0823451 0.23141

Moving the camera on the 'x' axis of the marker (tilt the camera up): Rxyz=-1.97658 -0.0506794 -0.020052

Moving the camera on the 'y' axis of the marker (incline the camera to the right): Rxyz=2.74544 -0.118551 -0.973627

Turn the camera 90 degrees (to the right): Rxyz=1.80194 -1.86528 0.746029

  1. Moving the marker instead of the camera, leaving the camera fixed looking to the marker:

Using the same initial position as in the previous case.

Moving the marker on its 'x' axis: Rxyz=2.23619 -0.0361307 -0.0843008

Moving the marker on its 'y' axis: Rxyz=-2.9065 -0.0291299 -1.13356

Moving the marker on its 'z' axis (90º turn to the right): Rxyz=1.78398 1.74161 -0.690203

I've been assuming that each number of the vector was the rotation on a respective axis but I think I'm assuming wrong as this values don't make so much sense if that was the case.


回答1:


How can I know the axis of my camera? I mean, is there a way to know where the x, y and z are facing?

This is defined in the OpenCV library. x-axis increases from left to right of the image, y-axis increases from top to bottom of the image, and z axis increases towards the front of the camera. Below image explains this axis selection.

How can I get the rotation of the camera from the rotation of the object wrt the camera?

rvec is the rotation of the marker with respect to the camera frame. You can convert rvec to a 3x3 rotation matrix using the built-in Rodrigues function. If the marker is aligned with camera frame, this rotation matrix should read 3x3 identity matrix.

If you get the inverse of this matrix (this is a rotation matrix, so the inverse is the transpose of the matrix), that is the rotation of the camera with respect to the marker.

Can someone explain me the meaning of the vectors better so I can really understand it? I think my main problem here is that I don't really know what those numbers mean for real.

tvec is the distance from the origin of the camera frame to the center of the detected marker (this is F_c - P line on the figure. rvec is as described in the above answer.



来源:https://stackoverflow.com/questions/59681995/how-to-get-the-camera-rotation-aruco-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!