Estimate camera pose from 3-D to 2-D point correspondences
the orientation and location of a calibrated camera in a world coordinate
system. The input
worldPoints must be defined
in the world coordinate system.
This function solves the perspective-n-point (PnP) problem using the perspective-three-point (P3P) algorithm . The function also eliminates spurious correspondences using the M-estimator sample consensus (MSAC) algorithm.
[___] = estimateWorldCameraPose(___, uses
additional options specified by one or more
arguments, using any of the preceding syntaxes.
Load previously calculated world-to-image correspondences.
data = load('worldToImageCorrespondences.mat');
Estimate the world camera pose.
[worldOrientation,worldLocation] = estimateWorldCameraPose(... data.imagePoints,data.worldPoints,data.cameraParams);
Plot the world points.
pcshow(data.worldPoints,'VerticalAxis','Y','VerticalAxisDir','down', ... 'MarkerSize',30); hold on plotCamera('Size',10,'Orientation',worldOrientation,'Location',... worldLocation); hold off
imagePoints— Coordinates of undistorted image points
Coordinates of undistorted image points, specified as an M-by-2 array of [x,y] coordinates. The number of image points, M, must be at least four.
The function does not account for lens distortion. You can either
undistort the images using the
before detecting the image points, or you can undistort the image
points themselves using the
worldPoints— Coordinates of world points
Coordinates of world points, specified as an M-by-3 array of [x,y,z] coordinates.
cameraParams— Object for storing camera parameters
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
MaxNumTrials— Maximum number of random trials
1000(default) | positive integer scalar
Maximum number of random trials, specified as the comma-separated pair consisting of
MaxNumTrials' and a positive
integer scalar. The actual number of trials
depends on the number of image and world points,
and the values for the
Increasing the number of trials improves the
robustness of the output at the expense of
Confidence— Confidence for finding maximum number of inliers
99(default) | scalar in the range (0,100)
Confidence for finding maximum number of inliers, specified
as the comma-separated pair consisting of '
and a scalar in the range (0,100). Increasing this value improves
the robustness of the output at the expense of additional computation.
MaxReprojectionError— Reprojection error threshold
1(default) | positive numeric scalar
Reprojection error threshold for finding outliers, specified as the comma-separated pair
consisting of '
MaxReprojectionError' and a positive numeric
scalar in pixels. Increasing this value makes the algorithm converge faster, but can
reduce the accuracy of the result.
worldOrientation— Orientation of camera in world coordinates
Orientation of camera in world coordinates, returned as a 3-by-3 matrix.
worldLocation— Location of camera
Location of camera, returned as a 1-by-3 unit vector.
 Gao, X.-S., X.-R. Hou, J. Tang, and H.F. Cheng. “Complete Solution Classification for the Perspective-Three-Point Problem.” IEEE Transactions on Pattern Analysis and Machine Intelligence. Volume 25,Issue 8, pp. 930–943, August 2003.
 Torr, P. H. S., and A. Zisserman. “MLESAC: A New Robust Estimator with Application to Estimating Image Geometry.” Computer Vision and Image Understanding. Volume 78, Issue 1, April 2000, pp. 138-156.
Usage notes and limitations:
Use in a MATLAB Function block is not supported.