Camera pose estimation

In order to estimate camera pose, the cv2.aruco.estimatePoseSingleMarkers() function  can be used, which estimates the pose for single markers. The pose is composed of a rotation and a translation vector. The signature is as follows:

cv.aruco.estimatePoseSingleMarkers( corners, markerLength, cameraMatrix, distCoeffs[, rvecs[, tvecs[, _objPoints]]] ) ->  rvecs, tvecs, _objPoints

Here, cameraMatrix and distCoeffs are the camera matrix and the distortion coefficients, respectively; they should be provided with the values obtained after the calibration process. The corners parameter is a vector containing the four corners of each detected marker. The markerLength parameter is the length of the marker side. Note that the returning translation vector will be in the same unit. This function returns rvecs (rotation vector), tvecs (translation vector) for each detected markers, and _objPoints (an array of object points of all of the detected marker corners).

The marker coordinate system is centered on the middle of the marker. Therefore, the coordinates of the four corners of the marker (in its own coordinate system) are the following:

Finally, ArUco also provides the cv.aruco.drawAxis() function, which can be used to draw the system axis for each detected marker.

The signature is as follows:

cv.aruco.drawAxis( image, cameraMatrix, distCoeffs, rvec, tvec, length ) -> image

All parameters have been previously introduced in the previous functions, except the length parameter, which sets the length of the drawn axis (in the same unit as tvec). The output of the script aruco_detect_markers_pose.py can be seen in the next screenshot:

In the previous screenshot you can see that only one marker has been detected and also the system axis for this marker has been drawn.