π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix(camera): export reproject_disparity_to_3D from geometry.camera (#6351)
Divyansh Rawat72e4ddde19f1
diff --git a/changelog.d/6351.fixed.md b/changelog.d/6351.fixed.mdnew file mode 100644index 000000000..d31f1c683--- /dev/null+++ b/changelog.d/6351.fixed.md@@ -0,0 +1 @@+`reproject_disparity_to_3D` is now exported from `kornia.geometry.camera` (and therefore from `kornia.geometry`), next to `StereoCamera`. It was documented on the stereo camera page but importable only from `kornia.geometry.camera.stereo`.diff --git a/kornia/geometry/camera/__init__.py b/kornia/geometry/camera/__init__.pyindex 763c13e24..b3c6c6594 100644--- a/kornia/geometry/camera/__init__.py+++ b/kornia/geometry/camera/__init__.py@@ -34,7 +34,7 @@ from .projection_orthographic import (unproject_points_orthographic,)from .projection_z1 import dx_project_points_z1, project_points_z1, unproject_points_z1-from .stereo import StereoCamera+from .stereo import StereoCamera, reproject_disparity_to_3D__all__ = ["PinholeCamera",@@ -50,6 +50,7 @@ __all__ = ["project_points","project_points_orthographic","project_points_z1",+ "reproject_disparity_to_3D","undistort_points_affine","undistort_points_kannala_brandt","unproject_points",diff --git a/kornia/geometry/camera/stereo.py b/kornia/geometry/camera/stereo.pyindex f7ce58efb..541e954f6 100644--- a/kornia/geometry/camera/stereo.py+++ b/kornia/geometry/camera/stereo.py@@ -23,6 +23,8 @@ from kornia.core.utils import is_compilingfrom kornia.geometry.conversions import convert_points_from_homogeneous, convert_points_to_homogeneousfrom kornia.geometry.grid import create_meshgrid+__all__ = ["StereoCamera", "StereoException", "reproject_disparity_to_3D"]+class StereoException(Exception):"""Handle errors related to stereo camera calibration and rectification."""@@ -78,12 +80,6 @@ class StereoCamera:returned. Request ``return_mask=True`` from :meth:`reproject_disparity_to_3D` to identify numericalreconstruction failures without changing those coordinates or their gradients.- .. warning::- The module-level :func:`~kornia.geometry.camera.stereo.reproject_disparity_to_3D` is rendered on- :doc:`/geometry.camera.stereo` but is in no ``__all__``, so it is not reachable as- ``kornia.geometry.reproject_disparity_to_3D``. Tracked as- `#4275 <https://github.com/kornia/kornia/issues/4275>`_.-Args:rectified_left_camera: The rectified left camera projection matrix of shape :math:`(B, 3, 4)`.rectified_right_camera: The rectified right camera projection matrix of shape :math:`(B, 3, 4)`.diff --git a/tests/api_surface.json b/tests/api_surface.jsonindex 9b0dc81e3..f3913efbf 100644--- a/tests/api_surface.json+++ b/tests/api_surface.json@@ -678,6 +678,7 @@"relative_transformation","remap","render_gaussian2d",+ "reproject_disparity_to_3D","rescale","resize","resize_to_be_divisible",@@ -777,12 +778,18 @@"project_points","project_points_orthographic","project_points_z1",+ "reproject_disparity_to_3D","undistort_points_affine","undistort_points_kannala_brandt","unproject_points","unproject_points_orthographic","unproject_points_z1"],+ "kornia.geometry.camera.stereo": [+ "StereoCamera",+ "StereoException",+ "reproject_disparity_to_3D"+ ],"kornia.geometry.conversions": ["ARKitQTVecs_to_ColmapQTVecs","ColmapQTVecs_to_ARKitQTVecs",diff --git a/tests/geometry/camera/test_stereo.py b/tests/geometry/camera/test_stereo.pyindex 37c2d8eb7..4fb318e74 100644--- a/tests/geometry/camera/test_stereo.py+++ b/tests/geometry/camera/test_stereo.py@@ -18,8 +18,8 @@import pytestimport torch-from kornia.geometry.camera import StereoCamera-from kornia.geometry.camera.stereo import StereoException, reproject_disparity_to_3D+from kornia.geometry.camera import StereoCamera, reproject_disparity_to_3D+from kornia.geometry.camera.stereo import StereoExceptionfrom testing.base import DYNAMO_UNAVAILABLE_REASON, BaseTester, dynamo_is_available@@ -562,3 +562,10 @@ class TestStereoCamera(BaseTester):assert cam.Q.shape == (1, 4, 4)with pytest.raises(StereoException, match="to have 3 dimensions"):StereoCamera(cam.rectified_left_camera[0], cam.rectified_right_camera[0])++ def test_reproject_disparity_to_3d_exported_from_camera(self):+ from kornia.geometry import camera++ assert hasattr(camera, "reproject_disparity_to_3D")+ assert "reproject_disparity_to_3D" in camera.__all__+ assert camera.reproject_disparity_to_3D is reproject_disparity_to_3D