cv.solvePnP - MATLAB File Help
cv.solvePnP

Finds an object pose from 3D-2D point correspondences

[rvec, tvec, success] = cv.solvePnP(objectPoints, imagePoints, cameraMatrix)
[...] = cv.solvePnP(..., 'OptionName', optionValue, ...)

Input

Output

Options

The function estimates the object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients. See the figure below (more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward and the Z-axis forward):

image

Points expressed in the world frame X_w are projected into the image plane [u,v] using the perspective projection model Pi and the camera intrinsic parameters matrix A:

[u; v; 1] = A * Pi * M_w^c * [X_w; Y_w; Z_w; 1]

[u; v; 1] = [fx 0 cx; 0 fy cy; 0 0 1] *
            [1 0 0 0; 0 1 0 0; 0 0 1 0] *
            [r11 r12 r13 tx; r21 r22 r23 ty; r31 r32 r33 tz] *
            [X_w; Y_w; Z_w; 1]

The estimated pose is thus the rotation (rvec) and the translation (tvec) vectors that allow to transform a 3D point expressed in the world frame into the camera frame:

[X_c; Y_c; Z_c; 1] = M_w^c * [X_w; Y_w; Z_w; 1]

[X_c; Y_c; Z_c; 1] = [r11 r12 r13 tx; r21 r22 r23 ty; r31 r32 r33 tz] *
                     [X_w; Y_w; Z_w; 1]

Notes

References

[gao2003complete]:

X.S. Gao, X.R. Hou, J. Tang, H.F. Chang; "Complete Solution Classification for the Perspective-Three-Point Problem", IEEE Trans. on PAMI, vol. 25, No. 8, p. 930-943, August 2003.

[Ke17]:

T. Ke, S. Roumeliotis; "An Efficient Algebraic Solution to the Perspective-Three-Point Problem", IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017 PDF

[morenoepnp]:

F. Moreno-Noguer, V. Lepetit and P. Fua; "EPnP: Efficient Perspective-n-Point Camera Pose Estimation".

[lepetit2009epnp]:

V. Lepetit, F. Moreno-Noguer, P. Fua; "EPnP: An accurate O(n) solution to the PnP problem". IJCV, vol. 81, No. 2, p. 155-166, 2009

[hesch2011direct]:

Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP". IEEE International Conference on Computer Vision, p. 383-390, 2011.

[penate2013exhaustive]:

A. Penate-Sanchez, J. Andrade-Cetto, F. Moreno-Noguer; "Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation". IEEE Trans. on PAMI, vol. 35, No. 10, p. 2387-2400, 2013.

See also