π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
set the results of division by zeror/near-zero to 1.0
jiangwei0309009a2a46
diff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.pyindex 33d38f467..ade34436a 100644--- a/kornia/geometry/conversions.py+++ b/kornia/geometry/conversions.py@@ -82,8 +82,10 @@ def convert_points_from_homogeneous(points: torch.Tensor) -> torch.Tensor:# we check for points at infinityz_vec: torch.Tensor = points[..., -1:]- z_vec = torch.where(torch.abs(z_vec) > EPS, z_vec, torch.sign(z_vec) * EPS)- scale: torch.Tensor = torch.tensor(1.) / z_vec+ # 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))return scale * points[..., :-1]