Problemcore
Perspective-n-point
Also called PnP, absolute pose problem, camera pose estimation.
Find the pose of a calibrated camera from n known 3D points and their image projections.
The perspective-n-point problem (PnP) asks for the position and orientation of a camera with known intrinsic matrix , given points whose coordinates are known in a world frame and their images . The answer is a rigid motion , so that is the point in the camera frame and . The pose has 6 degrees of freedom and each point gives 2 equations, so three points are the minimum. Three points give up to four poses, solved by P3P; more points fix the pose and average the noise, as in EPnP. With wrong matches, a minimal solver runs inside RANSAC, and the best pose is refined by minimizing the reprojection error. If is not known, the problem becomes camera resectioning.
In plain words
You have a photo, and you know where some objects in it are in the real world, for example the corners of a building on a map. You also know the lens of the camera. You want to know where the camera stood and in which direction it pointed. Each known point seen in the photo gives a line of sight that must pass through it. Three points are enough to fix the camera, but they can allow up to four answers. A fourth point usually tells which answer is right. With many points, small errors in the photo matter less.
Definition
Input. World points , their image points , and the intrinsic matrix . Then the normalized image points are known. Some matches may be wrong.
Output. A rotation and a translation such that each correct match satisfies with positive depth . The camera center is . With noise, the output minimizes a chosen cost:
- Reprojection error. , where . Under independent Gaussian image noise this is the maximum likelihood estimate.
- Object space error. The sum of the squared distances from to the ray of . It has no image meaning, but it treats near and far points alike and gives simpler algebra.
- Algebraic error. A linear residual such as , used to get a starting pose.
Ambiguities. Unlike relative pose, there is no free scale: the world points fix the units. For several poses fit exactly, and positive depth is part of the problem.
Variants
- Minimal case, P3P. gives a polynomial of degree 4 and up to four poses; see P3P.
- Planar scenes. If all points lie on one plane, the image of the plane is a homography , and four points in general position on the plane give the pose by homography decomposition.
- Unknown focal length. With only the focal length unknown, the problem has 7 unknowns and needs four points.
- Unknown calibration. With fully unknown, the matrix has 11 degrees of freedom and six points are needed; see DLT camera resectioning and camera matrix decomposition.
- Generalized cameras. Rays that do not pass through one center, as in a multi-camera rig, give the generalized pose problem; see generalized camera model.
- Lines and points. Known 3D lines and their images give more equations and can replace points.
- Known rotation. If is known, for example from an inertial sensor, each point gives two linear equations in , and two points are enough.
Examples
Two poses from three points. Take the world points , and , and the camera , . The normalized images are , and . P3P finds two poses with positive depths: the true one, with depths , and a second one, turned by about degrees, with and depths . Both fit the three images exactly.
A fourth point decides. The point has the image under the true pose and under the second one, so its observed image selects the true pose.
Non-example. If all points lie on one line, every rotation about that line fits as well as any other, and the pose is not determined.
Known algorithms
| algorithm | points | output | notes |
|---|---|---|---|
| P3P, Grunert's method and its variants | 3 | up to 4 poses | minimal; used inside RANSAC; a fourth point selects |
| EPnP | 4 or more | one pose | time; four virtual control points |
| DLT camera resectioning | 6 or more | , then , , | does not use the known ; linear |
| homography decomposition | 4 or more on a plane | one pose | for planar targets |
| nonlinear refinement | all inliers | one pose | Levenberg-Marquardt on the reprojection error, from any of the above |
The usual pipeline is: match image features to known 3D points, run P3P inside RANSAC to find the inliers, compute EPnP on the inliers, and refine with Levenberg-Marquardt on the reprojection error.
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| EPnP | Θ(n) worst · average · best | Θ(n) extra | deterministicexactofflineiterative | 1 language |
| P3P | Θ(n) worst · average · best | Θ(1) extra | deterministicexactofflineiterative | 1 language |
Bounds
- Degrees of freedom. 3 for and 3 for , so 6. Each point gives 2 equations, so 3 points are the minimum.
- Number of solutions. Three points not on a line give at most four poses with positive depths, the real positive roots of a quartic; up to four can occur.
- Uniqueness. Four or more points on a plane, no three on a line, give a unique pose. Six or more points in general position give a unique pose by the linear method, even without .
- Time. Any method must read the points, so time is needed. EPnP reaches ; the minimal solvers take constant time.
- Degenerate cases. Points on a line never fix the pose. For three points, poses near the danger cylinder, the cylinder through the three points perpendicular to their plane, are unstable, because two solutions meet there.
Reductions
- To absolute orientation. Once the depths of the points are known, the camera frame coordinates are known, and follows by aligning two point sets, the Kabsch algorithm, a form of Wahba's problem. P3P and EPnP both end this way.
- From resectioning. With known, a camera matrix from DLT resectioning gives , but the left block must then be forced to be a rotation.
- Dual of triangulation. Point triangulation finds a point from known cameras; PnP finds a camera from known points. Bundle adjustment refines both.
- Relation to relative pose. Relative pose works from 2D to 2D matches and leaves the scale free; PnP works from 3D to 2D matches and fixes it.
Applications
- Structure from motion. Each new image in incremental structure from motion is registered by PnP against the points already reconstructed.
- Visual odometry and SLAM. Tracking the camera against a local map, as in visual odometry.
- Calibration. The pose of a calibration target in each image, as in Zhang's calibration method, is a planar PnP problem.
- Augmented reality and robotics. Placing virtual objects on a known marker, or finding the pose of a known object for a robot to grasp.
- Localization. Finding where a photo was taken from matches with a 3D model of a place.
References
- Martin A. Fischler and Robert C. Bolles, Random sample consensus, a paradigm for model fitting with applications to image analysis and automated cartography, Communications of the ACM 24(6), 1981, 381-395, the location determination problem, its minimal case with three points, and its solution inside RANSAC
- Robert M. Haralick, Chung-Nan Lee, Karsten Ottenberg and Michael Nolle, Review and analysis of solutions of the three point perspective pose estimation problem, International Journal of Computer Vision 13(3), 1994, 331-356, the review of the classical three-point solutions and their numerical stability
- Vincent Lepetit, Francesc Moreno-Noguer and Pascal Fua, EPnP: An Accurate O(n) Solution to the PnP Problem, International Journal of Computer Vision 81(2), 2009, 155-166, the problem for n points, the survey of earlier methods and the linear-time solution
- Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Section 11.2, Pose estimation
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag CE8KQ1 Edit this page History Report an error Markdown