After obtaining the rotation and translation, we project four points from the object coordinate space to the preceding image: tip of the nose, x axis direction, y axis direction, and z axis direction, and draw the arrows in the preceding image:
vector<Point3f> objectPointsForReprojection {
objectPoints[2], // tip of nose
objectPoints[2] + Point3f(0,0,15), // nose and Z-axis
objectPoints[2] + Point3f(0,15,0), // nose and Y-axis
objectPoints[2] + Point3f(15,0,0) // nose and X-axis
};
//...
vector<Point2f> projectionOutput(objectPointsForReprojection.size());
projectPoints(objectPointsForReprojection, rvec, tvec, K, Mat(), projectionOutput);
arrowedLine(out, projectionOutput[0], projectionOutput[1], Scalar(255,255,0));
arrowedLine(out, projectionOutput[0], projectionOutput[2], Scalar(0,255,255));
arrowedLine(out, projectionOutput[0], projectionOutput[3], Scalar(255,0,255));
This results in a visualization of the direction the face is pointing, as shown in the following screenshots: