π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix indices in inverse_pose
edgarriba3ba8f6e3cdc6
diff --git a/test/test_functional.py b/test/test_functional.pyindex 7e152dbe2..b8b0c55e3 100644--- a/test/test_functional.py+++ b/test/test_functional.py@@ -178,10 +178,13 @@ class Tester(unittest.TestCase):def test_inverse_pose(self):# generate input data- batch_size = 2+ batch_size = 1eye_size = 4 # identity 4x4dst_pose_src = create_random_homography(batch_size, eye_size)+ dst_pose_src[:, -1] = 0.0+ dst_pose_src[:, -1, -1] = 1.0+ import pdb;pdb.set_trace()# compute the inverse of the posesrc_pose_dst = dgm.inverse_pose(dst_pose_src)diff --git a/torchgeometry/functional.py b/torchgeometry/functional.pyindex 7f93ad413..b699951f2 100644--- a/torchgeometry/functional.py+++ b/torchgeometry/functional.py@@ -139,8 +139,8 @@ def inverse_pose(pose):pose_inv = pose.clone()pose_inv[..., :3, 0:3] = torch.transpose(pose[..., :3, :3], 1, 2)- pose_inv[..., :3, 2:3] = torch.matmul(- -1.0 * pose_inv[..., :3, :3], pose[..., :3, 2:3])+ pose_inv[..., :3, 3:4] = torch.matmul(+ -1.0 * pose_inv[..., :3, :3], pose[..., :3, 3:4])if len(pose_shape) == 2:pose_inv = torch.squeeze(pose_inv, dim=0)