目录
- EPnP: An Accurate O(n) Solution to the PnP Problem
- Opencv.solvePnP documentation
- similar functions
- cv::SOLVEPNP_EPNP: Paper 008
EPnP: An Accurate O(n) Solution to the PnP Problem
Opencv.solvePnP documentation
solvePnP
bool cv::solvePnP(
InputArray objectPoints,
InputArray imagePoints,
InputArray cameraMatrix,
InputArray distCoeffs,
OutputArray rvec,
OutputArray tvec,
bool useExtrinsicGuess = false,
int flags = SOLVEPNP_ITERATIVE
)
Finds an object pose from 3D-2D point correspondences.
This function returns the rotation and the translation vectors that transform a 3D point expressed in the object coordinate frame to the camera coordinate frame, using different methods:
- P3P methods (SOLVEPNP_P3P, SOLVEPNP_AP3P): need 4 input points to return a unique solution.
- SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar(共面).
- SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation. Number of input points must be 4. Object points must be defined in the following order:
point 0: [-squareLength / 2, squareLength / 2, 0]
point 1: [ squareLength / 2, squareLength / 2, 0]
point 2: [ squareLength / 2, -squareLength / 2, 0]
point 3: [-squareLength / 2, -squareLength / 2, 0] - for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
Flags of solvePnP
-
cv::SOLVEPNP_ITERATIVE Default solution. Iterative method is based on a Levenberg-Marquardt optimization. In this case the function finds such a pose that minimizes reprojection error, that is the sum of squared distances between the observed projections “imagePoints” and the projected (using cv::projectPoints ) “objectPoints”. Initial solution for non-planar(非平面) “objectPoints” needs at least 6 points and uses the DLT algorithm. Initial solution for planar “objectPoints” needs at least 4 points and uses pose from homography decomposition(单应性分解).
-
cv::SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang “Complete Solution Classification for the Perspective-Three-Point Problem”. In this case the function requires exactly 4 object and image points.=>same as use solveP3P with same flag
-
cv::SOLVEPNP_AP3P Method is based on the paper of T. Ke, S. Roumeliotis “An Efficient Algebraic Solution to the Perspective-Three-Point Problem” . In this case the function requires exactly 4 object and image points.=>same as use solveP3P with same flag
-
cv::SOLVEPNP_EPNP Method has been introduced by F. Moreno-Noguer, V. Lepetit and P. Fua in the paper “EPnP: Efficient Perspective-n-Point Camera Pose Estimation” .
-
cv::SOLVEPNP_DLS Broken implementation. Using this flag will fallback to EPnP.
-
cv::SOLVEPNP_UPNP Broken implementation. Using this flag will fallback to EPnP.
-
cv::SOLVEPNP_IPPE Method is based on the paper of T. Collins and A. Bartoli. “Infinitesimal Plane-Based Pose Estimation”. This method requires coplanar object points.
-
cv::SOLVEPNP_IPPE_SQUARE Method is based on the paper of Toby Collins and Adrien Bartoli. “Infinitesimal Plane-Based Pose Estimation”. This method is suitable for marker pose estimation. It requires 4 coplanar object points defined in the following order:
point 0: [-squareLength / 2, squareLength / 2, 0]
point 1: [ squareLength / 2, squareLength / 2, 0]
point 2: [ squareLength / 2, -squareLength / 2, 0]
point 3: [-squareLength / 2, -squareLength / 2, 0] -
cv::SOLVEPNP_SQPNP Method is based on the paper “A Consistently Fast and Globally Optimal Solution to the Perspective-n-Point Problem” by G. Terzakis and M.Lourakis. It requires 3 or more points.
similar functions
-
cv::solveP3P()
Finds an object pose from 3 3D-2D point correspondences. -
cv::solvePnPGeneric()
Finds an object pose from 3D-2D point correspondences.
flags:
- P3P methods (SOLVEPNP_P3P, SOLVEPNP_AP3P)
- SOLVEPNP_IPPE
- SOLVEPNP_IPPE_SQUARE
-
solvePnPRansac()
using the RANSAC scheme -
solvePnPRefineLM()
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution. -
solvePnPRefineVVS()
Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
cv::SOLVEPNP_EPNP: Paper 008
论文内容:
propose a non-iterative solution to the PnP problem—the estimation of the pose of a cali- brated camera from n 3D-to-2D point correspondences— whose computational complexity grows linearly with n.
EPNP是求解PnP问题的非迭代方法。
优势是:
- 时间复杂度低,O(n),其他的是指数级,所以耗时短;
- 不依赖初始化;
- 鲁棒性高;
- 误差小。
- 用高斯牛顿方法可以进一步提高准确率,但计算耗时不会太大。
看论文里的实验数据,EPNP方法求得的rotation和translation存在随着匹配点数的增多,逐渐收敛趋于稳定的过程
图上看的话,噪声恒定的情况下,差不多10个点左右趋于收敛。