Пример #1
0
 def test_shift(self, device, dtype):
     pts1 = torch.zeros(3, 2, device=device, dtype=dtype)[None]
     pts2 = torch.tensor([[1.0, 0.0], [2.0, 0.0], [2.0, 2.0]],
                         device=device,
                         dtype=dtype)[None]
     H = torch.tensor([[1.0, 0.0, 1.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]],
                      dtype=dtype,
                      device=device)[None]
     expected = torch.tensor([0.0, 1.0, 5.0], device=device,
                             dtype=dtype)[None]
     assert_close(oneway_transfer_error(pts1, pts2, H),
                  expected,
                  atol=1e-4,
                  rtol=1e-4)
Пример #2
0
 def test_batch(self, device, dtype):
     batch_size = 5
     pts1 = torch.rand(batch_size, 3, 2, device=device, dtype=dtype)
     pts2 = torch.rand(batch_size, 3, 2, device=device, dtype=dtype)
     H = utils.create_random_homography(1, 3).type_as(pts1).to(device)
     assert oneway_transfer_error(pts1, pts2, H).shape == (batch_size, 3)
Пример #3
0
 def test_smoke(self, device, dtype):
     pts1 = torch.rand(1, 6, 2, device=device, dtype=dtype)
     pts2 = torch.rand(1, 6, 2, device=device, dtype=dtype)
     H = utils.create_random_homography(1, 3).type_as(pts1).to(device)
     assert oneway_transfer_error(pts1, pts2, H).shape == (1, 6)