Opencv – How to draw 3D Coordinate Axes with OpenCV for face pose estimation

3dcamera-calibrationcomputer visionimage processingopencv

Suppose I have got the face euler angles (pitch, yaw, roll). How can draw the 3D Coordinate Axes which show the face pose?

Here is an example from here:

enter image description here

Best Answer

This can be done in pure OpenCV as long as you have your camera parameters. You should be able to create three vectors corresponding to axis x, y, z (basically points [0,0,0] [1, 0, 0], [0, 1, 0], [0, 0, 1] which you will later project into the image plane. You should first rotate those points according to your yaw/pitch/roll (e.g. by multiplying them by a rotation matrix).

In order to project 3D points to the image plane, use the projectPoints function. It takes 3D points, camera parameters and generates 2D image points. Once you have the image points, you can simply use the line function to draw lines between the projected central point ([0,0,0] in 3D) and each of the resulting projections of the axis points.

Related Topic