Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

docs(epipolar): weights in find_essential are ignored by design, not a defect (#5522)

Dmytro Mishkin6a51755c6e44
diff --git a/changelog.d/5522.fixed.md b/changelog.d/5522.fixed.md
new file mode 100644
index 000000000..84cb181ba
--- /dev/null
+++ b/changelog.d/5522.fixed.md
@@ -0,0 +1 @@
+`find_essential` now documents that `weights` is intentionally ignored for compatibility, including for `N > 5`, rather than listing it as a known defect. Positive weights leave an exact five-point sample's null space unchanged; for larger sets they can affect the least-squares fit.
diff --git a/kornia/geometry/epipolar/essential.py b/kornia/geometry/epipolar/essential.py
index 4f55eb0f2..85f0b1c5c 100644
--- a/kornia/geometry/epipolar/essential.py
+++ b/kornia/geometry/epipolar/essential.py
@@ -54,7 +54,8 @@ def run_5point(points1: torch.Tensor, points2: torch.Tensor, weights: Optional[t
Args:
points1: A set of calibrated points in the first image with a tensor shape :math:`(B, N, 2), N>=5`.
points2: A set of points in the second image with a tensor shape :math:`(B, N, 2), N>=5`.
- weights: Not used, kept for compatibility.
+ weights: Not used, kept for compatibility, including for :math:`N > 5`. Positive weights leave the null
+ space of an exact five-point sample unchanged; for larger sets they can affect the least-squares fit.
Returns:
the computed essential matrix with shape :math:`(B, 10, 3, 3)`.
@@ -868,12 +869,13 @@ def find_essential(
copied back, which on an Apple M1 was also faster than a float32 solve on the device. A sample whose five
design rows are rank deficient, such as one with a repeated correspondence, has no unique solution: ten
``NaN`` slots and a zero gradient.
- - Known defects: ``weights`` is ignored (`#4876 <https://github.com/kornia/kornia/issues/4876>`_).
Args:
points1: A set of points in the first image with a tensor shape :math:`(B, N, 2), N>=5`.
points2: A set of points in the second image with a tensor shape :math:`(B, N, 2), N>=5`.
- weights: Accepted with a shape of :math:`(B, N)` and ignored (see Known defects).
+ weights: Accepted with a shape of :math:`(B, N)` and ignored for compatibility, including for :math:`N > 5`.
+ Positive weights leave the null space of an exact five-point sample unchanged; for larger sets they can
+ affect the least-squares fit.
Returns:
the computed essential matrices with shape :math:`(B, 10, 3, 3)`.
diff --git a/tests/geometry/epipolar/test_essential.py b/tests/geometry/epipolar/test_essential.py
index e62d6a833..e11acf154 100644
--- a/tests/geometry/epipolar/test_essential.py
+++ b/tests/geometry/epipolar/test_essential.py
@@ -1119,11 +1119,11 @@ class TestConventionEssential(BaseTester):
assert (R_sw - R).abs().max() > 0.1
assert (t_sw - t).abs().max() > 0.5
- def test_wart_find_essential_ignores_weights_4876(self, device, dtype):
+ def test_convention_find_essential_ignores_weights_4876(self, device, dtype):
two_view = two_view_scene(device, dtype)
_skip_find_essential(device, dtype)
- # #4876: weights is documented per correspondence but ignored: an outlier with weight 0, all-zero weights and
- # all-one weights give the same output (NaN slots compared as 0). Once weights are used these differ.
+ # #4876: weights are intentionally ignored for compatibility, including for this non-minimal sample:
+ # an outlier with weight 0, all-zero weights and all-one weights give the same output (NaN slots compared as 0).
n1, n2 = _normalized(two_view["K1"], two_view["x1"]), _normalized(two_view["K2"], two_view["x2"])
p1 = torch.cat([n1, torch.tensor([[[0.4, -0.3]]], device=device, dtype=dtype)], 1)
p2 = torch.cat([n2, torch.tensor([[[-0.35, 0.25]]], device=device, dtype=dtype)], 1)