# Revision history [back]

You have the right idea, however rvecs is not a rotation matrix. It is a rotation vector, as described HERE.

That is the function you need to use. Convert your rotation vector to a rotation matrix with that function, transpose it, then convert it back.

However, that's not going to be enough. drawAxis uses the rvecs and tvecs to determine where to draw the axis lines. So if you simply change the rvecs, then you will be altering where it thinks the marker is in relation to the camera. You will need to make your own version of the drawAxis function that uses your original rvecs to draw, and your new rvecs to calculate what to draw.

Fortunately this is fairly simple.

The code to draw axis looks like this:

// project axis points
vector< Point3f > axisPoints;
axisPoints.push_back(Point3f(0, 0, 0));
axisPoints.push_back(Point3f(length, 0, 0));
axisPoints.push_back(Point3f(0, length, 0));
axisPoints.push_back(Point3f(0, 0, length));
vector< Point2f > imagePoints;
projectPoints(axisPoints, _rvec, _tvec, _cameraMatrix, _distCoeffs, imagePoints);

// draw axis lines
line(_image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), 3);
line(_image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), 3);
line(_image, imagePoints[0], imagePoints[3], Scalar(255, 0, 0), 3);


You need to rotate those axis points by your rotation matrix so they are aligned with the camera axis, and then draw those lines instead.

Give that a try, and let us know if you have any more questions.