Beispiel #1
0
    def _test_example_intrinsics(self, example):
        p3c, p2, f, c = (example[k] for k in ['p3c', 'p2', 'f', 'c'])
        actual_f, actual_c = calculate_intrinsics(np.reshape(p3c, (-1, 3)),
                                                  np.reshape(p2, (-1, 2)))
        np.testing.assert_allclose(actual_f, f)
        np.testing.assert_allclose(actual_c, c)

        actual_p2 = project(p3c, f, c)
        np.testing.assert_allclose(actual_p2, p2, atol=1.0)
 def test_2d(self):
     n = 1000
     p3 = np.random.uniform(size=(n, 3))
     p3[:, 2] += 2
     f = np.array([1.2, 1.1])
     c = np.array([200., 201.])
     p2 = p3[:, :2] / p3[:, -1:] * f + c
     actual_f, actual_c = calculate_intrinsics(p3, p2)
     np.testing.assert_allclose(actual_f, f)
     np.testing.assert_allclose(actual_c, c)
Beispiel #3
0
 def _calculate_intrinsics(self):
     self.attrs['f'], self.attrs['c'] = calculate_intrinsics(
         np.reshape(self._example['p3c'], (-1, 3)),
         np.reshape(self._example['p2'], (-1, 2)))