Ask Your Question
1

aruco giving strange rotations.

asked 2017-04-22 06:38:04 -0600

antithing gravatar image

updated 2017-04-24 15:56:15 -0600

Hi, I am tracking aruco markers in an openCv application. I am using the left frame of a calibrated stereo camera, so the image is undistorted and rectified. As such, i pass 0 parameters to the distortion matrix.

I have the camera pointing down at the floor, and measure the angle with an IMU. The result is 37 degrees in pitch.

I have a marker set up, on the floor, as straight as I can get it in front of the camera.

When I print the rvecs value returned from the marker, I would expect to see something like:

Yaw 0, Roll 0, Pitch -37

but what I do see ( after applying *180 / M_PI;) is:

[131.865, -0.295742, 1.04376]

The rotation is only one axis, which looks right, but the value is a long way off from what it should be. Am I missing something? Or is this as accurate as Aruco gets with a single marker?

(the axis displayed in frame looks correct, but the value returned does not)

As a bonus question.. is it possible to return quaternions from Aruco tracking?

Thanks!

EDIT:

I now have:

cv::Mat expected;
cv::Rodrigues(rvecs[i], expected);

Eigen::Quaterniond mOrientationEigen = toQuaternionOg(expected);


Eigen::Quaterniond toQuaternionOg(const cv::Mat &M)
{
    Eigen::Matrix<double, 3, 3> eigMat = toMatrix3d(M);
    Eigen::Quaterniond q(eigMat);

    return q;
}

But the returned quaternions are garbage: 3.89581e-181.20234e+173.03257e-186.61337e+09

Where am I going wrong here?

edit retag flag offensive close merge delete

Comments

Did you check if when you print eigMat is equal to M?

Eduardo gravatar imageEduardo ( 2017-04-25 03:22:18 -0600 )edit

Check if you are handling doubles or floats. Probably is somehow you are mixing types, the result would be garbage...

rafde gravatar imagerafde ( 2017-09-12 07:49:08 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-04-22 18:36:58 -0600

Eduardo gravatar image

updated 2017-04-22 18:37:57 -0600

rvec is an axis-angle rotation vector (see Rodrigues' rotation formula). To get a quaternion, you will have to do the conversion yourself.

For the first question, in this case as the rotation is only about one axis I think that it is fine to compare directly. Otherwise, in the general case, you will need to convert the rotation vector to the appropriate Euler angle convention to properly compare.

rvec represents the rotation for the camera pose, maybe check that the IMU frame is correctly aligned with the camera frame?

edit flag offensive delete link more

Comments

Ah, so rvecs *180 / M_PI is NOT equivalent to yaw pitch and roll? I can use: cv::Mat expected; cv::Rodrigues(rvecs[i], expected); to get my rotation matrix, is this correct? Thanks again! I have edited my question with more code...

antithing gravatar imageantithing ( 2017-04-24 14:43:15 -0600 )edit

Hey, I'm really interested in this topic. Did you find any solution with the IMU-rvec values?? I've got the exact same problem here.

rafde gravatar imagerafde ( 2017-09-12 07:46:56 -0600 )edit

Hi, yup I did. I ended up using the built in opencv function 'cv2eigen', works great. Convert 'rvec' to a Mat, then use cv::Rodrigues to get the Rotation Matrix, then use:

Eigen::Matrix<double, 3, 3> eigMat;
    cv2eigen(M, eigMat);
    Eigen::Quaterniond q(eigMat);
stillNovice gravatar imagestillNovice ( 2017-09-17 06:26:59 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-22 06:38:04 -0600

Seen: 3,080 times

Last updated: Apr 24 '17