Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Aruco - draw position+orientation relative to marker

Hi, I want to draw the orientation of my camera relative to a detected marker, I use the aruco module. So far I have a working code (basically the aruco example detect_markers.cpp from /opencv/opencv_contrib-master/modules/aruco/samples) that detects markers and draws a coordinate system onto them.

Now I want to draw that coordinate system i a way that it shows the orientation of the camera relative to the marker.

According to the opencv docs "the returned transformation from "estimatePoseSingleMarkers" (i.e. rvecs and tvecs) is the one that transforms points from each marker coordinate system to the camera coordinate system."

aruco::estimatePoseSingleMarkers(corners, markerLength, camMatrix, distCoeffs, rvecs,

So if I take the function aruco::drawAxis(imageCopy, camMatrix, distCoeffs, rvecs[i], tvecs[i], markerLength * 0.8f); and pass it the inverse of the rotation matrix it should show me the orientation of my camera right? Unfortunately my code gives an error:

Here is how I do the transformation: CvMat rvecs_trans; cvTranspose(rvecs[i], &rvecs_trans);

If I pass rvecs_trans to the drawAxis function it wont compile:

invalid initialization of reference of type ‘cv::InputArray {aka const cv::_InputArray&}’ from expression of type ‘CvMat*’ aruco::drawAxis(imageCopy, camMatrix, distCoeffs, &rvecs_trans, tvecs[i], markerLength * 0.8f);

Can anyone help me? I'm very new to opencv...