# [SOLVED]trouble converting Euler angles to rotation matrix for cal [closed] I have this matched pair of stereo cameras that come with calibration data including rotation and translation between the left and right cameras. The left to right rotation is given as a set of 3 euler angles, and I'm told the rotation is passive in the order x->y->z. The coordinate system they use would have the z axis shooting out away from you, the y axis headed down to your feet, and the x axis shooting off from your right shoulder. I'm trying to convert these three angles into a matrix that I can use in stereoRectify. If I don't set the rotation matrix everything seems to work okay, but when I try to create my own rotation matrix the image is barely recognizable.

I tried the following:

    //next we need to compose the 3 rotations into their matrix forms
cv::Mat_<double> R_x(3,3);

R_x << 1, 0, 0,
0, cos(E_x), -sin(E_x),
0, sin(E_x), cos(E_x);

cv::Mat_<double> R_y(3,3);

R_y << cos(E_y), 0, sin(E_y),
0, 1, 0
-sin(E_y), 0, cos(E_y);

cv::Mat_<double> R_z(3,3);

R_z << cos(E_z), -sin(E_z), 0,
sin(E_z), cos(E_z), 0,
0, 0, 1;

R = R_x * R_y * R_z;


And also tried re-ording the last multiplication step which gives me different rotations but nothing that looks correct. How should I be doing this?

Thank you

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by supra56 close date 2020-06-09 06:23:14.937122

Sort by » oldest newest most voted For R_y and R_z. You can't used index 0.

//next we need to compose the 3 rotations into their matrix forms
cv::Mat_<double> R_x(3,3);

R_x << 1, 0, 0,
0, cos(E_x), -sin(E_x),
0, sin(E_x), cos(E_x);

cv::Mat_<double> R_y(3,3);

R_y << cos(E_y), 0, sin(E_y),
0, 1, 0
-sin(E_y), 0, cos(E_y);

cv::Mat_<double> R_z(3,3);

R_z << cos(E_z), -sin(E_z), 0,
sin(E_z), cos(E_z), 0,
0, 0, 1;

R = R_x * R_y * R_z;

more

Official site

GitHub

Wiki

Documentation