[][src]Function opencv::calib3d::estimate_affine_partial_2d

pub fn estimate_affine_partial_2d(
    from: &dyn ToInputArray,
    to: &dyn ToInputArray,
    inliers: &mut dyn ToOutputArray,
    method: i32,
    ransac_reproj_threshold: f64,
    max_iters: size_t,
    confidence: f64,
    refine_iters: size_t
) -> Result<Mat>

Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.

Parameters

  • from: First input 2D point set.
  • to: Second input 2D point set.
  • inliers: Output vector indicating which points are inliers.
  • method: Robust method used to compute transformation. The following methods are possible:
  • cv::RANSAC - RANSAC-based robust method
  • cv::LMEDS - Least-Median robust method RANSAC is the default method.
  • ransacReprojThreshold: Maximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.
  • maxIters: The maximum number of robust method iterations.
  • confidence: Confidence level, between 0 and 1, for the estimated transformation. Anything between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
  • refineIters: Maximum number of iterations of refining algorithm (Levenberg-Marquardt). Passing 0 will disable refining, so the output matrix will be output of robust method.

Returns

Output 2D affine transformation (4 degrees of freedom) matrix inline formula or empty matrix if transformation could not be estimated.

The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust estimation.

The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more.

Estimated transformation matrix is: block formula Where inline formula is the rotation angle, inline formula the scaling factor and inline formula are translations in inline formula axes respectively.

Note: The RANSAC method can handle practically any ratio of outliers but need a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers.

See also

estimateAffine2D, getAffineTransform

C++ default parameters

  • inliers: noArray()
  • method: RANSAC
  • ransac_reproj_threshold: 3
  • max_iters: 2000
  • confidence: 0.99
  • refine_iters: 10