def test_rotate_z(self, device, dtype): R1 = torch.tensor([[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype) R2 = torch.tensor([[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype) t1 = kornia.vec_like(3, R1) t2 = kornia.vec_like(3, R2) R_expected = R2.clone() t_expected = t1 R, t = epi.relative_camera_motion(R1, t1, R2, t2) assert_close(R_expected, R) assert_close(t_expected, t)
def test_shape(self, batch_size, eye_size, device, dtype): B, N = batch_size, eye_size image = torch.rand(B, 3, 4, 4, device=device, dtype=dtype) vec = kornia.vec_like(N, image) assert vec.shape == (B, N, 1) assert vec.device == image.device assert vec.dtype == image.dtype
def test_translation(self, device, dtype): R1 = torch.tensor([[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype) t1 = torch.tensor([[[10.0], [0.0], [0.0]]]).type_as(R1) R2 = kornia.eye_like(3, R1) t2 = kornia.vec_like(3, t1) R_expected = R1.clone() t_expected = -t1 R, t = epi.relative_camera_motion(R1, t1, R2, t2) assert_close(R_expected, R) assert_close(t_expected, t)
def test_smoke(self, device, dtype): image = torch.rand(1, 3, 4, 4, device=device, dtype=dtype) vec = kornia.vec_like(3, image) assert vec.shape == (1, 3, 1) assert vec.device == image.device assert vec.dtype == image.dtype