Ask Your Question
0

[SOLVED]trouble converting Euler angles to rotation matrix for cal [closed]

asked 2020-06-08 10:06:06 -0600

eric_engineer gravatar image

updated 2020-06-09 06:23:40 -0600

supra56 gravatar image

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[0]), -sin(E_x[0]),
       0, sin(E_x[0]), cos(E_x[0]);

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

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

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

R_z << cos(E_z[0]), -sin(E_z[0]), 0,
       sin(E_z[0]), cos(E_z[0]), 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 flag offensive 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

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-06-09 04:49:50 -0600

supra56 gravatar image

updated 2020-06-09 04:50:24 -0600

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[0]), -sin(E_x[0]),
       0, sin(E_x[0]), cos(E_x[0]);

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

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

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

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

R = R_x * R_y * R_z;
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-06-08 10:06:06 -0600

Seen: 1,779 times

Last updated: Jun 09 '20