Ask Your Question

Aruco markers with openCv, get the 3d corner coordinates?

asked 2017-09-22 07:45:24 -0500

stillNovice gravatar image

I am detecting a printed Aruco marker using opencv 3.2:

aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,tvecs);

this returns a translation and rotation vector for the marker. What I need, is the 3d coordinates for each corner of the marker.

As i know the marker length, i could do something like

corner1 = tvecs[0] - markerlength /2;
corner2 = tvecs[0] + markerlength /2;

But is there an better way? Or an existing function?

How can i return the 3d corner coordinates of a marker, in world space (where the camera is at 0,0,0)?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-09-23 11:30:38 -0500

Tetragramm gravatar image

So the way that function works, you pass in the location of the four corners in the image, and the marker length. It assumes the first corner is (0,0,0), and then the others are (ml, 0, 0), (0, ml, 0)...

The output is rvec and tvec, which gives you the orientation of the camera relative to the marker. Since you want the orientation of the marker relative to the camera, you need to invert those values.

Mat R;
Rodrigues(rvec, R);
R = R.t();
tvec = -R*tvec;
Rodrigues(R, rvec);

Then you can take the 3d values of the points (0,0,0), (ml, 0, 0) ... and transform them with rvec and tvec. You'll have to make the values yourself, so recommend looking at the code of estimatePoseSingleMarkers to make sure you've got the same values, or your results will be wrong.

Mat R;
Rodrigues(rvec, R);
3dpoint = R*point+tvec
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-09-22 07:45:24 -0500

Seen: 2,172 times

Last updated: Sep 23 '17