π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Fix max_samples in ransac.py
Dmytro Mishkin790d32b32793
diff --git a/kornia/geometry/ransac.py b/kornia/geometry/ransac.pyindex 556928a31..a526ddc68 100644--- a/kornia/geometry/ransac.py+++ b/kornia/geometry/ransac.py@@ -97,9 +97,12 @@ class RANSAC(Module):def max_samples_by_conf(n_inl: int, num_tc: int, sample_size: int, conf: float) -> float:"""Formula to update max_iter in order to stop iterations earlierhttps://en.wikipedia.org/wiki/Random_sample_consensus."""+ eps = 1e-9+ if num_tc <= sample_size:+ return 1.0if n_inl == num_tc:return 1.0- return math.log(1.0 - conf) / math.log(1.0 - math.pow(n_inl / num_tc, sample_size))+ return math.log(1.0 - conf) / math.log(max(eps, 1.0 - math.pow(n_inl / num_tc, sample_size)))def estimate_model_from_minsample(self, kp1: Tensor, kp2: Tensor) -> Tensor:batch_size, sample_size = kp1.shape[:2]