Exemplo n.º 1
0
    def test_simple(self, device, dtype):
        P = torch.tensor(
            [[[308.0, 139.0, 231.0, 84.0], [481.0, 161.0, 358.0, 341.0],
              [384.0, 387.0, 459.0, 102.0]]],
            device=device,
            dtype=dtype,
        )

        K_expected = torch.tensor(
            [[[17.006138, 122.441254, 390.211426],
              [0.0, 228.743622, 577.167480], [0.0, 0.0, 712.675232]]],
            device=device,
            dtype=dtype,
        )

        R_expected = torch.tensor(
            [[[0.396559, 0.511023, -0.762625], [
                0.743249, -0.666318, -0.060006
            ], [0.538815, 0.543024, 0.644052]]],
            device=device,
            dtype=dtype,
        )

        t_expected = torch.tensor([[[-6.477699], [1.129624], [0.143123]]],
                                  device=device,
                                  dtype=dtype)

        K_estimated, R_estimated, t_estimated = epi.KRt_from_projection(P)
        assert_allclose(K_estimated, K_expected, atol=1e-4, rtol=1e-4)
        assert_allclose(R_estimated, R_expected, atol=1e-4, rtol=1e-4)
        assert_allclose(t_estimated, t_expected, atol=1e-4, rtol=1e-4)
Exemplo n.º 2
0
    def test_krt_from_projection(self, device, dtype):
        P = torch.tensor([[
            [10., 0., 30., 100.],
            [0., 20., 40., 160.],
            [0., 0., 1., 3.],
        ]],
                         device=device,
                         dtype=dtype)

        K_expected = torch.tensor([[
            [10., 0., 30.],
            [0., 20., 40.],
            [0., 0., 1.],
        ]],
                                  device=device,
                                  dtype=dtype)

        R_expected = torch.tensor([[
            [1., 0., 0.],
            [0., 1., 0.],
            [0., 0., 1.],
        ]],
                                  device=device,
                                  dtype=dtype)

        t_expected = torch.tensor([[[1.], [2.], [3.]]],
                                  device=device,
                                  dtype=dtype)

        K_estimated, R_estimated, t_estimated = epi.KRt_from_projection(P)
        assert_allclose(K_estimated, K_expected)
        assert_allclose(R_estimated, R_expected)
        assert_allclose(t_estimated, t_expected)
Exemplo n.º 3
0
    def test_shape(self, batch_size, device, dtype):
        B: int = batch_size
        P = torch.rand(B, 3, 4, device=device, dtype=dtype)
        K, R, t = epi.KRt_from_projection(P)

        assert K.shape == (B, 3, 3)
        assert R.shape == (B, 3, 3)
        assert t.shape == (B, 3, 1)
Exemplo n.º 4
0
    def test_krt_from_projection(self, device, dtype):
        P = torch.tensor([[[10.0, 0.0, 30.0, 100.0], [0.0, 20.0, 40.0, 160.0],
                           [0.0, 0.0, 1.0, 3.0]]],
                         device=device,
                         dtype=dtype)

        K_expected = torch.tensor(
            [[[10.0, 0.0, 30.0], [0.0, 20.0, 40.0], [0.0, 0.0, 1.0]]],
            device=device,
            dtype=dtype)

        R_expected = torch.tensor(
            [[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]],
            device=device,
            dtype=dtype)

        t_expected = torch.tensor([[[1.0], [2.0], [3.0]]],
                                  device=device,
                                  dtype=dtype)

        K_estimated, R_estimated, t_estimated = epi.KRt_from_projection(P)
        assert_allclose(K_estimated, K_expected, atol=1e-4, rtol=1e-4)
        assert_allclose(R_estimated, R_expected, atol=1e-4, rtol=1e-4)
        assert_allclose(t_estimated, t_expected, atol=1e-4, rtol=1e-4)
Exemplo n.º 5
0
 def test_smoke(self, device, dtype):
     P = torch.randn(1, 3, 4, device=device, dtype=dtype)
     K, R, t = epi.KRt_from_projection(P)
     assert K.shape == (1, 3, 3)
     assert R.shape == (1, 3, 3)
     assert t.shape == (1, 3, 1)