Ejemplo n.º 1
0
 def test_from_to_fundamental(self, device, dtype):
     F_mat = torch.rand(1, 3, 3, device=device, dtype=dtype)
     K1 = torch.rand(1, 3, 3, device=device, dtype=dtype)
     K2 = torch.rand(1, 3, 3, device=device, dtype=dtype)
     E_mat = epi.essential_from_fundamental(F_mat, K1, K2)
     F_hat = epi.fundamental_from_essential(E_mat, K1, K2)
     assert_allclose(F_mat, F_hat, atol=1e-4, rtol=1e-4)
Ejemplo n.º 2
0
 def test_shape(self, batch_size, device, dtype):
     B: int = batch_size
     E_mat = torch.rand(B, 3, 3, device=device, dtype=dtype)
     K1 = torch.rand(B, 3, 3, device=device, dtype=dtype)
     K2 = torch.rand(1, 3, 3, device=device, dtype=dtype)  # check broadcasting
     F_mat = epi.fundamental_from_essential(E_mat, K1, K2)
     assert F_mat.shape == (B, 3, 3)
Ejemplo n.º 3
0
 def test_shape_large(self, device, dtype):
     E_mat = torch.rand(1, 2, 3, 3, device=device, dtype=dtype)
     K1 = torch.rand(1, 2, 3, 3, device=device, dtype=dtype)
     K2 = torch.rand(1, 1, 3, 3, device=device,
                     dtype=dtype)  # check broadcasting
     F_mat = epi.fundamental_from_essential(E_mat, K1, K2)
     assert F_mat.shape == (1, 2, 3, 3)
Ejemplo n.º 4
0
    def test_from_to_essential(self, device, dtype):
        scene = utils.generate_two_view_random_scene(device, dtype)

        F_mat = scene['F']
        E_mat = epi.essential_from_fundamental(F_mat, scene['K1'], scene['K2'])
        F_hat = epi.fundamental_from_essential(E_mat, scene['K1'], scene['K2'])

        F_mat_norm = epi.normalize_transformation(F_mat)
        F_hat_norm = epi.normalize_transformation(F_hat)
        assert_close(F_mat_norm, F_hat_norm, atol=1e-4, rtol=1e-4)
Ejemplo n.º 5
0
    def test_from_fundamental(self, device, dtype):

        scene = utils.generate_two_view_random_scene(device, dtype)

        F_mat = scene['F']

        K1 = scene['K1']
        K2 = scene['K2']

        E_mat = epi.essential_from_fundamental(F_mat, K1, K2)
        F_hat = epi.fundamental_from_essential(E_mat, K1, K2)

        F_mat_norm = epi.normalize_transformation(F_mat)
        F_hat_norm = epi.normalize_transformation(F_hat)
        assert_allclose(F_mat_norm, F_hat_norm)
Ejemplo n.º 6
0
 def test_smoke(self, device, dtype):
     E_mat = torch.rand(1, 3, 3, device=device, dtype=dtype)
     K1 = torch.rand(1, 3, 3, device=device, dtype=dtype)
     K2 = torch.rand(1, 3, 3, device=device, dtype=dtype)
     F_mat = epi.fundamental_from_essential(E_mat, K1, K2)
     assert F_mat.shape == (1, 3, 3)