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)[source]¶
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, e.g. “homography” or “fundamental”. 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)[source]¶
Main forward method to execute the RANSAC algorithm.
- Parameters
kp1 (torch.Tensor) – source image keypoints \((N, 2)\).
kp2 (torch.Tensor) – distance image keypoints \((N, 2)\).
weights (torch.Tensor) – optional correspondences weights. Not used now Default:
None
- Return type
- Returns
Estimated model, shape of \((1, 3, 3)\).
The inlier/outlier mask, shape of \((1, N)\), where N is number of input correspondences.