[][src]Function opencv::calib3d::solve_pnp_ransac

pub fn solve_pnp_ransac(
    object_points: &dyn ToInputArray,
    image_points: &dyn ToInputArray,
    camera_matrix: &dyn ToInputArray,
    dist_coeffs: &dyn ToInputArray,
    rvec: &mut dyn ToOutputArray,
    tvec: &mut dyn ToOutputArray,
    use_extrinsic_guess: bool,
    iterations_count: i32,
    reprojection_error: f32,
    confidence: f64,
    inliers: &mut dyn ToOutputArray,
    flags: i32
) -> Result<bool>

Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.

Parameters

  • objectPoints: Array 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.
  • imagePoints: Array 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.
  • cameraMatrix: Input camera matrix inline formula .
  • distCoeffs: Input vector of distortion coefficients inline formula of 4, 5, 8, 12 or 14 elements. If the vector is NULL/empty, the zero distortion coefficients are assumed.
  • rvec: Output rotation vector (see @ref Rodrigues ) that, together with tvec, brings points from the model coordinate system to the camera coordinate system.
  • tvec: Output translation vector.
  • useExtrinsicGuess: Parameter used for @ref 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.
  • iterationsCount: Number of iterations.
  • reprojectionError: Inlier threshold value used by the RANSAC procedure. The parameter value is the maximum allowed distance between the observed and computed point projections to consider it an inlier.
  • confidence: The probability that the algorithm produces a useful result.
  • inliers: Output vector that contains indices of inliers in objectPoints and imagePoints .
  • flags: Method for solving a PnP problem (see @ref solvePnP ).

The function estimates an object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients. This 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 @ref projectPoints ) objectPoints. The use of RANSAC makes the function resistant to outliers.

Note:

  • An example of how to use solvePNPRansac for object detection can be found at opencv_source_code/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/
  • The default method used to estimate the camera pose for the Minimal Sample Sets step is #SOLVEPNP_EPNP. Exceptions are:
  • if you choose #SOLVEPNP_P3P or #SOLVEPNP_AP3P, these methods will be used.
  • if the number of input points is equal to 4, #SOLVEPNP_P3P is used.
  • The method used to estimate the camera pose using all the inliers is defined by the flags parameters unless it is equal to #SOLVEPNP_P3P or #SOLVEPNP_AP3P. In this case, the method #SOLVEPNP_EPNP will be used instead.

C++ default parameters

  • use_extrinsic_guess: false
  • iterations_count: 100
  • reprojection_error: 8.0
  • confidence: 0.99
  • inliers: noArray()
  • flags: SOLVEPNP_ITERATIVE