Beispiel #1
0
 def test_shape_large(self, device, dtype):
     F_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
     E_mat = epi.essential_from_fundamental(F_mat, K1, K2)
     assert E_mat.shape == (1, 2, 3, 3)
Beispiel #2
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)
Beispiel #3
0
 def test_shape(self, batch_size, device, dtype):
     B: int = batch_size
     F_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
     E_mat = epi.essential_from_fundamental(F_mat, K1, K2)
     assert E_mat.shape == (B, 3, 3)
Beispiel #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)
Beispiel #5
0
    def test_from_fundamental_Rt(self, device, dtype):

        scene = utils.generate_two_view_random_scene(device, dtype)

        E_from_Rt = epi.essential_from_Rt(scene['R1'], scene['t1'], scene['R2'], scene['t2'])

        E_from_F = epi.essential_from_fundamental(scene['F'], scene['K1'], scene['K2'])

        E_from_Rt_norm = epi.normalize_transformation(E_from_Rt)
        E_from_F_norm = epi.normalize_transformation(E_from_F)
        # TODO: occasionally failed with error > 0.04
        assert_close(E_from_Rt_norm, E_from_F_norm, rtol=1e-3, atol=1e-3)
Beispiel #6
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)
Beispiel #7
0
 def test_smoke(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)
     assert E_mat.shape == (1, 3, 3)