I am using @arturo ofxAruco to track a single marker. The marker is printed on a small piece of paper. I place the paper in front of the camera and rotate the paper clockwise, as showing in this snapshot of a video.
in red is the x axis, blue the z axis and green the y axis.
The y axis is the one that (mostly) points towards the camera and I would like to have a figure (in degrees) about the rotation of the marker/paper plane around it.
I have attempted a couple of things and plotted the resulting numbers but none seems to be monotonically increasing/decreasing something that would help me figure out which number is the rotation.
ok initially I attempted to read Rvec , the rotation vector of the marker
cv::Mat rotationMatrix = it->Rvec; cout << "rot [" << rotationMatrix.at<float>(0,0) << "," << rotationMatrix.at<float>(1,0) << "," << rotationMatrix.at<float>(2,0) << "] ";
over 2 full revolutons of the paper, the result was
Rvec[1,0] and Rvec[2,0] look promising, but the min/max values are not on pi or 2*pi boundaries. So converting Rvec from rads (if it is even in rads) to degrees does not provide a nice 180->-180 degrees rotation. Is there some operation missing that I should carry out to get the rotation ?
It is also abit weird because I see [1,0] and [2,0] , so axes y,z respectively rotating. Whereas I would expected X and z to be rotating. Also the 2 axis that are rotating should have 90deg phase difference and not be (more or less) mirrored as is the case here. no?
due to these, I tried some more stuff:
double pos, orie; it->OgreGetPoseParameters(pos,orie); ofQuaternion qua(orie,orie,orie,orie); qua.normalize(); float rotaxis; ofVec3f axis; qua.getRotate(rotaxis,axis); cout << "qua [" <<axis.x <<","<<axis.y<<","<<axis.z <<"] ang=" << rotaxis <<endl ;
here I am getting the orientation quaternion and extracting the axis-rotation characteristics : “axis”- the unit verctor and the angle “rotaxis”. plotting these does not help (and perhaps was never meant to)
This is a mess so I also tried getting the world coordinates and extracting the rotation (pitch,raw,yaw) from there also:
ofMatrix4x4 mat = aruco.getModelViewMatrix(0); //there is only 1 marker ofQuaternion qua2 = mat.getRotate(); ofVec3f rots = qua2.getEuler(); cout << " rots[" <<rots.x <<","<<rots.y<<","<<rots.z <<"]" << endl;
again the plot is not helpful
clearly I do not know how to grab the rotation around the axis that points towards the camera. I think it is the y axis from this guide: http://docs.opencv.org/master/d5/dae/tutorial_aruco_detection.html#gsc.tab=0 (search for “Y:green”)
Could you please explain how to get it and if there is a method available to do it?