How to properly estimate the Z rotation using ArUco Markers

asked 2020-04-06 13:06:20 -0600

image description

I am trying to determine the car's (x,y) coordinates and its rotation angle theta, illustrated above. (Picture represents a very simple car model as seen from above) I will attach my phone on top of the car, and using ArUco markers I would like to determine my car's/phone's pose relative to the world, so that I can extract the X and Y transalations, and the Z rotation which should match theta.

I have managed to shift from camera coordinate system to marker coordinate system using the answer to this question: Pose of camera from the pose of marker

Here is a result: image description The 'new rVec' and 'new tVec' represent the rotation and translation vector in the marker's coordinate system. In this picture everything is fine. My rotation vector is good as I am currently holding my phone at a >90 degree angle (1.57 rad) on X and the translation vector matches the distances. I can also see by using the drawAxis method provided in the ArUco library that the marker is detected correctly, so I expected the results to be good.

Here however: image description I have rotated my phone 90 degrees toward the left (on the Z axis) and moved the phone to the right so that I can capture the marker in the picture. The translation vector and the drawAxis give me good results, but the rotation vector is not what I was expecting. I was expecting the rotation on Z to match my theta angle, which should have been around 1.57 the equivalent of pi/2. I also have some rotation on both X and Y which was unexpected, as I thought I should only have a >90 degree angle on Y, and a 0 degree angle on X (The opposite of the previous picture).

I have also noticed some other weird behaviour. Here is a video I made that shows my problems: ArUco rotation Troubleshoot

There are 2 problems I see: 1) The marker is rotated at a 180 degrees angle yet the z rotation vector isn't close to 3.14 (pi). 2) I am intentionally moving the camera, rotating it on the X axis. For some reason this movement modifies the Z and Y rotation as well.

My main idea was to get the rotation of the camera relative to the marker's coordinate system, and extract the Z rotation. Shouldn't the rotation on Z match the theta angle provided in the first picture? I can also provide the code for the pose estimation but I didn't think it's necessary since the drawAxis method's results seem perfect.

Also, if there are any easier or better ways to determine the theta angle using a camera attached to a car please let me know!

edit retag flag offensive close merge delete