Example #1
0
 def test_smoke(self, device, dtype):
     P1 = torch.rand(1, 3, 4, device=device, dtype=dtype)
     P2 = torch.rand(1, 3, 4, device=device, dtype=dtype)
     points1 = torch.rand(1, 1, 2, device=device, dtype=dtype)
     points2 = torch.rand(1, 1, 2, device=device, dtype=dtype)
     points3d = epi.triangulate_points(P1, P2, points1, points2)
     assert points3d.shape == (1, 1, 3)
Example #2
0
 def test_shape(self, batch_size, num_points, device, dtype):
     B, N = batch_size, num_points
     P1 = torch.rand(B, 3, 4, device=device, dtype=dtype)
     P2 = torch.rand(1, 3, 4, device=device, dtype=dtype)
     points1 = torch.rand(1, N, 2, device=device, dtype=dtype)
     points2 = torch.rand(B, N, 2, device=device, dtype=dtype)
     points3d = epi.triangulate_points(P1, P2, points1, points2)
     assert points3d.shape == (B, N, 3)
Example #3
0
    def test_two_view(self, device, dtype):
        num_views: int = 2
        num_points: int = 10
        scene: Dict[str,
                    torch.Tensor] = epi.generate_scene(num_views, num_points)

        P1 = scene['P'][0:1]
        P2 = scene['P'][1:2]
        x1 = scene['points2d'][0:1]
        x2 = scene['points2d'][1:2]

        X = epi.triangulate_points(P1, P2, x1, x2)
        x_reprojected = kornia.transform_points(scene['P'],
                                                X.expand(num_views, -1, -1))

        assert_allclose(scene['points3d'], X, rtol=1e-4, atol=1e-4)
        assert_allclose(scene['points2d'], x_reprojected)