Ask Your Question

'Mapping' Aruco markers?

asked 2017-10-04 13:43:11 -0600

stillNovice gravatar image

updated 2017-10-04 14:00:22 -0600

I have a calibrated camera, and an application that tracks Aruco markers using opencv 3.2.

What I am trying to do is Map the locations of the markers as they enter camera frame, in real time. So, for example, i have three markers.

In frame 1, I can see marker A. I want this to be located at 0,0,0 in world space. I move the camera and can now see marker A and marker B. I move the camera again, and can now see marker B and marker C, but no longer marker A.

What I want to do, is get the location and rotation of each marker in world space, relative to each other. It seems like I should have enough information to do this, but I am struggling to work out the workflow.

What I am doing is:

Keeping a vector of Markers, and keeping track of which I have seen before and which i have not. As a new marker comes in to view, I store the rvec and tvec and flip it from camera pose to get the marker location in world space.

This alone does not do what I need, it seems to give the marker location relative to the camera, but not relative to each other and therefore the world. I assume that i need to somehow 'chain' the marker locations to get the world-space location of the new ones as the camera moves. is this correct? If anyone could give me a workflow, or steps to follow here, it would be very much appreciated.

thank you.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-10-04 19:13:56 -0600

Tetragramm gravatar image

So you find the rvec and tvec to each marker. Let's say A and B. So you know where the camera is relative to each marker.

What you need to do is invert one (I can never remember which one, I think B) and then yes, chain it to the other one.

You invert by using this bit of code.

Rodrigues(rotation, R);
R = R.t();
translation = -R * translation;
Rodrigues(R, rotation);

Then you use the function composeRT to do the actual chaining. Then you know where B is, so once A passes from the frame and C shows up, you can do the same, just not starting from 0,0,0.

edit flag offensive delete link more


I am trying to impleent your suggestion and I have some questions with that. 1- rotation is 3x1 matrix and R is 3x3 ? 2- R.t() is transpose? 3- Minus R means that multiply every element in the R by -1 ? 4- Minus R Multiply translation vector is -> 3x3 matrix DOT PRODUCT 3x1 matrix? I searched many codes and questions but I want to make sure about that. I am doing the right thing. Simple yes and no answers will suffice. Thank you so much for the info. After the implementation, I will share the python code.

yeser gravatar imageyeser ( 2018-05-08 10:53:50 -0600 )edit

Very close, but number 4 is the matrix product, and the output should be another 3x1 matrix.

Tetragramm gravatar imageTetragramm ( 2018-05-08 17:18:47 -0600 )edit

Thanks for the answer. Another one: How can I test that I am succeed to wrote the code.? Code(as image, not yet finished): Program detects two ArUco markers, invert the second one and compose them together. Result is another tvec and rvec. I am summing tvec and first markers tvec, multiplying rvec and first markers rvec. And trying to show that with projectPoints and cv.imshow. That's the code basically. Fail image: . At last, the code (not complete of course):

yeser gravatar imageyeser ( 2018-05-08 17:29:31 -0600 )edit

You can test by first, ensuring that if you do it twice, you end up with what you started with. Second, use a known rotation and translation.

Also, I looked it up, and in numpy matrix multiplication is done using the .dot() function. So there's that.

Tetragramm gravatar imageTetragramm ( 2018-05-08 18:23:59 -0600 )edit

Thanks for the answers. Unfortunately I couldn't code it well. I didn't want to mess the comments up and I created another question. Hope you can check it out. Thanks for clearing things for me. Question link:

yeser gravatar imageyeser ( 2018-05-09 08:06:44 -0600 )edit

Question Tools

1 follower


Asked: 2017-10-04 13:43:11 -0600

Seen: 2,842 times

Last updated: Oct 04 '17