Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

pass the test

jiangwei6799bb0e377c
diff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.py
index ade34436a..32787cfce 100644
--- a/kornia/geometry/conversions.py
+++ b/kornia/geometry/conversions.py
@@ -83,9 +83,12 @@ def convert_points_from_homogeneous(points: torch.Tensor) -> torch.Tensor:
# we check for points at infinity
z_vec: torch.Tensor = points[..., -1:]
# set the results of division by zeror/near-zero to 1.0
- # follow the convention of opencv: https://github.com/opencv/opencv/pull/14411/files
- scale: torch.Tensor = torch.where(torch.abs(z_vec) > EPS,
- torch.tensor(1.) / z_vec, torch.ones_like(z_vec))
+ # follow the convention of opencv:
+ # https://github.com/opencv/opencv/pull/14411/files
+ scale: torch.Tensor = torch.where(
+ torch.abs(z_vec) > EPS,
+ torch.tensor(1.) / z_vec,
+ torch.ones_like(z_vec))
return scale * points[..., :-1]
diff --git a/test/geometry/test_conversions.py b/test/geometry/test_conversions.py
index 226477972..74b3b59ef 100644
--- a/test/geometry/test_conversions.py
+++ b/test/geometry/test_conversions.py
@@ -171,12 +171,16 @@ class TestConvertPointsFromHomogeneous:
[1, 2, 1],
[0, 1, 2],
[2, 1, 0],
+ [-1, -2, -1],
+ [0, 1, -2],
]).to(torch.device(device_type))
expected = torch.FloatTensor([
[1, 2],
[0, 0.5],
[2, 1],
+ [1, 2],
+ [0, -0.5],
]).to(torch.device(device_type))
# to euclidean
@@ -189,12 +193,16 @@ class TestConvertPointsFromHomogeneous:
[2, 1, 0],
], [
[0, 1, 2],
+ ], [
+ [0, 1, -2],
]]).to(torch.device(device_type))
expected = torch.FloatTensor([[
[2, 1],
], [
[0, 0.5],
+ ], [
+ [0, -0.5],
]]).to(torch.device(device_type))
# to euclidean