π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
test(calibration): give TestDistortPoints.test_jit a well-conditioned camera (#4552)
Dipak Chaudharife35482b3902
diff --git a/tests/geometry/calibration/test_distort.py b/tests/geometry/calibration/test_distort.pyindex fb04abb36..c38f54cbf 100644--- a/tests/geometry/calibration/test_distort.py+++ b/tests/geometry/calibration/test_distort.py@@ -328,10 +328,18 @@ class TestDistortPoints(BaseTester):self.assert_close(product, torch.eye(3, device=device, dtype=dtype)[None])def test_jit(self, device, dtype):- points = torch.rand(1, 1, 2, device=device, dtype=dtype)- K = torch.rand(1, 3, 3, device=device, dtype=dtype)- new_K = torch.rand(1, 3, 3, device=device, dtype=dtype)- distCoeff = torch.rand(1, 4, device=device, dtype=dtype)+ # A random K has fx, fy < 1, and with random coefficients the distortion polynomial+ # overflows float16 on some draws, so eager and scripted both return nan and cannot be+ # compared (#4400). A real camera and small coefficients keep every draw finite. The+ # points span 100 px so the normalized radius reaches about 1, and k1 and k2 move the+ # output past the tolerance on most draws, and on essentially every float32/float64+ # draw; points in [0, 1) px would leave only p1 and p2 visible. new_K normalizes and K+ # denormalizes, so new_K is a distinct matrix: with K == new_K a scripted path that+ # swapped the two would return the same answer.+ points = 100 * torch.rand(1, 1, 2, device=device, dtype=dtype)+ K = _k_asymmetric(device, dtype)+ new_K = 0.9 * _k_asymmetric(device, dtype)+ distCoeff = 0.1 * torch.rand(1, 4, device=device, dtype=dtype)inputs = (points, K, distCoeff, new_K)op = distort_points