Ejemplo n.º 1
0
    def test_two_view(self, device, dtype):
        scene = utils.generate_two_view_random_scene(device, dtype)

        R1, t1 = scene['R1'], scene['t1']
        R2, t2 = scene['R2'], scene['t2']

        E_mat = epi.essential_from_Rt(R1, t1, R2, t2)

        R, t = epi.relative_camera_motion(R1, t1, R2, t2)
        t = torch.nn.functional.normalize(t, dim=1)

        Rs, ts = epi.motion_from_essential(E_mat)

        rot_error = (Rs - R).abs().sum((-2, -1))
        vec_error = (ts - t).abs().sum((-1))

        rtol: float = 1e-4
        assert (rot_error < rtol).any() & (vec_error < rtol).any()
Ejemplo n.º 2
0
 def eval_vec(input):
     return epi.motion_from_essential(input)[1]
Ejemplo n.º 3
0
 def eval_rot(input):
     return epi.motion_from_essential(input)[0]
Ejemplo n.º 4
0
 def test_shape(self, batch_shape, device, dtype):
     E_mat = torch.rand(batch_shape, device=device, dtype=dtype)
     Rs, Ts = epi.motion_from_essential(E_mat)
     assert Rs.shape == batch_shape[:-2] + (4, 3, 3)
     assert Ts.shape == batch_shape[:-2] + (4, 3, 1)
Ejemplo n.º 5
0
 def test_smoke(self, device, dtype):
     E_mat = torch.rand(1, 3, 3, device=device, dtype=dtype)
     Rs, Ts = epi.motion_from_essential(E_mat)
     assert Rs.shape == (1, 4, 3, 3)
     assert Ts.shape == (1, 4, 3, 1)