fdcl-gwu / aruco-markers

Working examples/tutorial for detection and pose estimation of ArUco markers with C++, including instructions to build and install OpenCV from source.
BSD 3-Clause "New" or "Revised" License
239 stars 71 forks source link

yaw, pitch, roll from pose estimation. #1

Closed rahulsharma11 closed 5 years ago

rahulsharma11 commented 5 years ago

Hi, I am using this project and have used all the necessary steps. This is a great project to use. Accuracy can be confirmed with the z measurement which is giving error in few mm only. Can i get yaw, pitch, roll from the same? I have done some mathematics on rvecs but not able to get correct yaw angle. Also i am not sure whether quaternion obtained are correct or not. Any guidance for that? Thanks.

kanishkegb commented 5 years ago

Do you have issues only with the yaw angle? If you are using a single marker, try using a marker board. This might help solving yaw angle related issues.

I usually work with rotation matrices and use the OpenCV function called Rodrigues to convert the rvec to a rotation matrix. After a brief search, I could not find a function to convert rvec to Euler angles in OpenCV. You may have to write your own function to convert the rotation matrix to Euler angles.

rahulsharma11 commented 5 years ago

Hi, Yes i have used Rodrigues function. I have followed this link- http://answers.opencv.org/question/143072/aruco-giving-strange-rotations/

But, i am not sure with the quaternion angle output. As i converted those quaternion to YPR, which are not correct. So i thought if there is builtin functionality that can be used to get quaternion from rvecs.

kanishkegb commented 5 years ago

I am sorry, but it is not clear what you are trying to say. Are you using the method described in the link in your comment to calculate the angles? rvec is not a quaternion.

As a side note, if you are confused, the YPR is relative to the camera frame as defined in the OpenCV documentation: x-axis increases from left to right of the image, y-axis increases from top to bottom of the image, and the z-axis points outwards the camera, with the origin on the top left corner of the image.

rahulsharma11 commented 5 years ago

No, I am not confused about the concept. I know rvec is rotational vectors, i have to convert it to rotational matrix and then to quaternion. I just gave that link as a reference i used. I have converted rvecs to matrix by using "Rodrigues function". Also have calculated the quaternion angles by using inbuilt eigen function "Eigen::Quaterniond". The thing is that i am not sure about quaternion that i got. So i asked any other way around here in this project exist to get quaternions .

kanishkegb commented 5 years ago

I personally have never used Eigen::Quaterniond, so it is hard to comment on that. I think the next logical step is to check the rotation matrix. Does the attitude representation by the rotation matrix makes sense? If so, your issue is with calculating the quaternion or Euler angles.