[][src]Function opencv::calib3d::estimate_affine_2d

pub fn estimate_affine_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 affine transformation between two 2D point sets.

It computes block formula

Parameters

  • from: First input 2D point set containing inline formula.
  • to: Second input 2D point set containing inline formula.
  • inliers: Output vector indicating which points are inliers (1-inlier, 0-outlier).
  • 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 matrix inline formula or empty matrix if transformation could not be estimated. The returned matrix has the following form: block formula

The function estimates an optimal 2D affine transformation between two 2D point sets using the selected robust algorithm.

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

Note: The RANSAC method can handle practically any ratio of outliers but needs 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

estimateAffinePartial2D, getAffineTransform

C++ default parameters

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