def test_volumetric(self, batch_size, num_frames, num_points, device, dtype): B, T, N = batch_size, num_frames, num_points point = torch.rand(B, T, N, 2, device=device, dtype=dtype) F_mat = torch.rand(B, T, 3, 3, device=device, dtype=dtype) lines_T_hops = torch.zeros(B, T, N, 3, device=device, dtype=dtype) for i in range(T): lines_T_hops[:, i, ...] = epi.compute_correspond_epilines(point[:, i, ...], F_mat[:, i, ...]) lines_one_hop = epi.compute_correspond_epilines(point, F_mat) assert_close(lines_T_hops, lines_one_hop, atol=1e-8, rtol=1e-8)
def test_opencv(self, device, dtype): point = torch.rand(1, 2, 2, device=device, dtype=dtype) F_mat = torch.rand(1, 3, 3, device=device, dtype=dtype) point = torch.tensor([[[0.9794, 0.7994], [0.8163, 0.8500]]], device=device, dtype=dtype) F_mat = torch.tensor( [[[0.1185, 0.4438, 0.9869], [0.5670, 0.9447, 0.4100], [0.1546, 0.2554, 0.4485]]], device=device, dtype=dtype) # generated with OpenCV using above points # import cv2 # lines_expected = cv2.computeCorrespondEpilines( # point.detach().numpy().reshape(-1, 1, 2), 0, # F_mat.detach().numpy()[0]).transpose(1, 0, 2) lines_expected = torch.tensor([[[0.64643687, 0.7629675, 0.35658622], [0.65710586, 0.7537983, 0.35616538]]], device=device, dtype=dtype) lines_est = epi.compute_correspond_epilines(point, F_mat) assert_allclose(lines_est, lines_expected, rtol=1e-4, atol=1e-4)
def test_shape(self, batch_size, num_points, device, dtype): B, N = batch_size, num_points point = torch.rand(B, N, 2, device=device, dtype=dtype) F_mat = torch.rand(B, 3, 3, device=device, dtype=dtype) lines = epi.compute_correspond_epilines(point, F_mat) assert lines.shape == (B, N, 3)
def test_smoke(self, device, dtype): point = torch.rand(1, 1, 2, device=device, dtype=dtype) F_mat = torch.rand(1, 3, 3, device=device, dtype=dtype) lines = epi.compute_correspond_epilines(point, F_mat) assert lines.shape == (1, 1, 3)