Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

docs(geometry): keep both depth warp namings and document them as the convention (#6328)

Adarsh Mishra94cabf256b8c
diff --git a/kornia/geometry/depth.py b/kornia/geometry/depth.py
index d9e353c62..7096a1f73 100644
--- a/kornia/geometry/depth.py
+++ b/kornia/geometry/depth.py
@@ -429,11 +429,9 @@ def warp_frame_depth(
:func:`~kornia.geometry.camera.perspective.project_points`, whose conventions apply.
- the sampling is bilinear ``grid_sample`` with a fixed ``align_corners=True`` and
``padding_mode="zeros"``; the output is :math:`(B, D, H, W)` with ``image_src``'s channels.
-
- .. warning::
- :class:`~kornia.geometry.depth.DepthWarper` performs the same warp under the **opposite** naming: this
- function's ``dst`` (holding the depth) is that class's ``src``, and ``image_src`` is its ``patch_dst``:
- `#4273 <https://github.com/kornia/kornia/issues/4273>`_.
+ - :class:`~kornia.geometry.depth.DepthWarper` and :func:`~kornia.geometry.depth.depth_warp` perform the
+ same warp under the opposite frame names: this function's ``dst`` (the frame holding the depth) is
+ their ``src``, and ``image_src`` is their ``patch_dst``. Both namings are kept.
Args:
image_src: image tensor in the source frame with shape :math:`(B,D,H,W)`.
@@ -510,14 +508,13 @@ class DepthWarper(nn.Module):
``align_corners=True`` normalized coordinates of the **destination** image.
- ``align_corners`` (default ``True``), ``mode`` and ``padding_mode`` are forwarded to ``grid_sample``.
:func:`~kornia.geometry.depth.depth_warp` is the functional form and exposes ``align_corners`` only.
+ - :func:`~kornia.geometry.depth.warp_frame_depth` performs the same warp under the opposite frame names:
+ this class's ``src`` (the frame holding the depth) is that function's ``dst``, and ``patch_dst`` is its
+ ``image_src``. Both namings are kept.
.. warning::
- :func:`~kornia.geometry.depth.warp_frame_depth` performs the same warp under the **opposite** naming:
- this class's ``src`` (holding the depth) is that function's ``dst``, and ``patch_dst`` is its
- ``image_src``; reading "dst" as "dst" across the two gives the inverse warp:
- `#4273 <https://github.com/kornia/kornia/issues/4273>`_. The two agree to rounding for float32/float64
- away from ``z = 0``, and split at ``z = 0``, where ``cam2pixel`` sends every pixel with a nonzero
- projected numerator far outside the image:
+ The two warps agree to rounding for float32/float64 away from ``z = 0``, and split at ``z = 0``, where
+ ``cam2pixel`` sends every pixel with a nonzero projected numerator far outside the image:
`#4267 <https://github.com/kornia/kornia/issues/4267>`_.
Args:
diff --git a/tests/geometry/test_depth.py b/tests/geometry/test_depth.py
index 1dffad364..3e55db5c9 100644
--- a/tests/geometry/test_depth.py
+++ b/tests/geometry/test_depth.py
@@ -1140,12 +1140,13 @@ class TestDepthWarperConventions(BaseTester):
self.assert_close(by_function, by_class)
assert (by_class - img).abs().max().item() > 0.1
- def test_wart_warp_frame_depth_and_depth_warper_name_the_depth_frame_oppositely_4273(self, device, dtype):
+ def test_convention_warp_frame_depth_and_depth_warper_name_the_depth_frame_oppositely_4273(self, device, dtype):
# kornia#4273: the two APIs produce the same warp from OPPOSITE argument names:
# warp_frame_depth(image_src=IMG, depth_dst=D, src_trans_dst=T)
# DepthWarper(pinhole_dst=cam(T)).compute_projection_matrix(pinhole_src=cam(I))(depth_src=D, patch_dst=IMG)
# Mapping 'dst' to 'dst' across the two gives the INVERSE warp (the swapped pair). The arguments are
- # keywords on purpose: the #4273 fix is a rename, so this pin fails when it lands.
+ # keywords on purpose: both namings are kept by design (#4273); this pin fails if either API renames
+ # its frames.
image = torch.arange(20.0, device=device, dtype=dtype).view(1, 1, 4, 5)
depth = torch.ones(1, 1, 4, 5, device=device, dtype=dtype)
identity = _eye4(device, dtype)