Keywords: rotation matrix Euler angle
Uses: Camera pose estimation, unmanned attitude estimation, various pose estimation
Article type: concept, Formula Summary ( This article does not take the process of demolition, if you want to know how the formula is introduced, please search the literature ), C + + function display
@Author: V_shawn
@Date: 2016-11-04
@Lab: [Email protected]
??
Objective
Camera calibration After the rotation of the matrix, and then how to use the rotation matrix to represent the attitude of the camera the problem is estimated to have troubled every study of this problem of new students, then this article gives me a way to help you less go fruitless. Of course there are any good ideas, or more cow's way also welcome message exchange treatise. Of course, the formula will not be pushed down to me, the reference is much better than me
Formula
has a rotation matrix
\[r\text{=}\left (\begin{matrix} {{r}_{11}} & {{r}_{12}} & {{r}_{13}} \ {{r}_{21}} & {{r}_{22}} & {r}_{2} 3}} \ \ {{r}_{31}} & {{r}_{32}} & {{r}_{33}} \\\end{matrix} \right) \]
Then you can find the rotation angle of each axis:
Z Axis:
Y-Axis
X-Axis
Note:atan2to beC + +medium function,atan2 (y,x)the practice: whenxthe absolute value ratioyuse when the absolute value is largeatan (y/x); In contrast to useatan (x/y). This guarantees a numerical stability.
The above formula means that the camera coordinate system wants to go completely parallel to the world coordinate system (i.e. XC parallel to xw,yc parallel to yw,zc parallel to ZW, and their direction is the same), need to rotate 3 times, set the original camera coordinate system to C0.
1, C0 rotation around its z axis, to obtain a new coordinate system C1;
2. C1 rotates around its y axis to obtain a new coordinate system C2 (note that the axis of rotation is the y-axis of C1, not the y-axis of C0);
3, C2 rotation around its y axis, to obtain a new coordinate system C3. At this point the C3 is completely parallel to the world coordinate system W.
Special Note: The rotation order is Z y x, remember not to swap.
C + + Programs
The code is easier.
The R11-r33 is presented from the rotation matrix as a double type variable.
//计算出相机坐标系的三轴旋转欧拉角,旋转后可以转出世界坐标系。
//旋转顺序为z、y、x
const double PI = 3.141592653;
double thetaz = atan2(r21, r11) / PI * 180;
double thetay = atan2(-1 * r31, sqrt(r32*r32 + r33*r33)) / PI * 180;
double thetax = atan2(r32, r33) / PI * 180;
Reference documents
Computing Euler angles from a rotation matrix. Gregory G. Slabaugh
Http://www.staff.city.ac.uk/~sbbh653/publications/euler.pdf
Solving the rotation angle/euler angle of three axes according to the camera rotation matrix