kornia.geometry.ransac

Module with RANSAC

class kornia.geometry.ransac.RANSAC(model_type='homography', inl_th=2.0, batch_size=2048, max_iter=10, confidence=0.99, max_lo_iters=5)

Module for robust geometry estimation with RANSAC. https://en.wikipedia.org/wiki/Random_sample_consensus.

Parameters:
  • model_type (str, optional) – type of model to estimate: “homography”, “fundamental”, “fundamental_7pt”, “homography_from_linesegments”. Default: "homography"

  • inliers_threshold – threshold for the correspondence to be an inlier.

  • batch_size (int, optional) – number of generated samples at once. Default: 2048

  • max_iterations – maximum batches to generate. Actual number of models to try is batch_size * max_iterations.

  • confidence (float, optional) – desired confidence of the result, used for the early stopping. Default: 0.99

  • max_local_iterations – number of local optimization (polishing) iterations.

forward(kp1, kp2, weights=None)

Main forward method to execute the RANSAC algorithm.

Parameters:
  • kp1 (Tensor) – source image keypoints \((N, 2)\).

  • kp2 (Tensor) – distance image keypoints \((N, 2)\).

  • weights (Optional[Tensor], optional) – optional correspondences weights. Not used now. Default: None

Return type:

Tuple[Tensor, Tensor]

Returns:

  • Estimated model, shape of \((1, 3, 3)\).

  • The inlier/outlier mask, shape of \((1, N)\), where N is number of input correspondences.