1 | initial version |
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