opencv solvePnP

https://docs.opencv.org/4.1.0/d9/d0c/group__calib3d.html#ga549c2075fac14829ff4a58bc931c033d

solvePnP()

bool cv::solvePnP(InputArray objectPoints,
  InputArray imagePoints,
  InputArray cameraMatrix,
  InputArray distCoeffs,
  OutputArray rvec,
  OutputArray tvec,
  bool useExtrinsicGuess = false,
  int flags = SOLVEPNP_ITERATIVE 
 )  
Python:
 retval, rvec, tvec=cv.solvePnP(objectPoints, imagePoints, cameraMatrix, distCoeffs[, rvec[, tvec[, useExtrinsicGuess[, flags]]]])

#include <opencv2/calib3d.hpp>

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

Parameters

objectPointsArray of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points. vector<Point3f> can be also passed here.
imagePointsArray of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel, where N is the number of points. vector<Point2f> can be also passed here.
cameraMatrixInput camera matrix A=⎡⎣⎢⎢fx000fy0cxcy1⎤⎦⎥⎥ .
distCoeffsInput vector of distortion coefficients (k1,k2,p1,p2[,k3[,k4,k5,k6[,s1,s2,s3,s4[,τx,τy]]]]) of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
rvecOutput rotation vector (see Rodrigues ) that, together with tvec , brings points from the model coordinate system to the camera coordinate system.
tvecOutput translation vector.
useExtrinsicGuessParameter used for SOLVEPNP_ITERATIVE. If true (1), the function uses the provided rvec and tvec values as initial approximations of the rotation and translation vectors, respectively, and further optimizes them.
flagsMethod for solving a PnP problem:
  • SOLVEPNP_ITERATIVE Iterative method is based on 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 projectPoints ) objectPoints .
  • 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" ([70]). In this case the function requires exactly four object and image points.
  • SOLVEPNP_AP3P Method is based on the paper of T. Ke, S. Roumeliotis "An Efficient Algebraic Solution to the Perspective-Three-Point Problem" ([107]). In this case the function requires exactly four object and image points.
  • 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" ([118]).
  • SOLVEPNP_DLS Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis. "A Direct Least-Squares (DLS) Method for PnP" ([91]).
  • SOLVEPNP_UPNP Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto, F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation" ([165]). In this case the function also estimates the parameters fx and fy assuming that both have the same value. Then the cameraMatrix is updated with the estimated focal length.
  • SOLVEPNP_AP3P Method is based on the paper of Tong Ke and Stergios I. Roumeliotis. "An Efficient Algebraic Solution to the Perspective-Three-Point Problem" ([107]). In this case the function requires exactly four object and image points.

 

 

zhangym@zhangym:~/opencv/samples/cpp$ sudo find . -type f | xargs grep solvePnP
[sudo] password for zhangym: 
./select3dobj.cpp:            solvePnP(Mat(boardPoints), Mat(foundBoardCorners), cameraMatrix,
./tutorial_code/calib3d/real_time_pose_estimation/src/main_detection.cpp:        if(good_matches.size() >= 4) // OpenCV requires solvePnPRANSAC to minimally have 4 set of points
./tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp:    bool correspondence = cv::solvePnP( list_points3d, list_points2d, A_matrix_, distCoeffs, rvec, tvec,
./tutorial_code/calib3d/real_time_pose_estimation/src/PnPProblem.cpp:    cv::solvePnPRansac( list_points3d, list_points2d, A_matrix_, distCoeffs, rvec, tvec,
./tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp:    solvePnP(objectPoints, corners1, cameraMatrix, distCoeffs, rvec1, tvec1);
./tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp:    solvePnP(objectPoints, corners2, cameraMatrix, distCoeffs, rvec2, tvec2);
./tutorial_code/features2D/Homography/decompose_homography.cpp:    solvePnP(objectPoints, corners1, cameraMatrix, distCoeffs, rvec1, tvec1);
./tutorial_code/features2D/Homography/decompose_homography.cpp:    solvePnP(objectPoints, corners2, cameraMatrix, distCoeffs, rvec2, tvec2);
 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值