Exemple #1
0
 def _calculate_extrinsics(self):
     p3w = self._example['p3w']
     p3c = self._example['p3c']
     R, t, k = calculate_extrinsics(np.reshape(p3w, (-1, 3)),
                                    np.reshape(p3c, (-1, 3)))
     assert (np.allclose(k, 1.0, atol=1e-3))
     self.attrs['r'] = np.array(euler_from_matrix_nh(R), dtype=np.float32)
     self.attrs['t'] = t
Exemple #2
0
 def _test_example_extrinsics(self, example):
     actual = {'k': 1.0}
     expected = {}
     p3w, p3c, actual['r'], actual['t'] = (example[k].astype(
         np.float32) for k in ['p3w', 'p3c', 'r', 't'])
     actual['R'] = euler_matrix_nh(*actual['r'])
     expected['R'], expected['t'], expected['k'] = \
         calculate_extrinsics(
             np.reshape(p3w, (-1, 3)), np.reshape(p3c, (-1, 3)))
     expected['r'] = np.array(euler_from_matrix_nh(expected['R']))
     assert (len(actual) == len(expected))
     for k in ['R', 'r', 't', 'k']:
         np.testing.assert_allclose(actual[k], expected[k], atol=1.0)
 def test_camera_extrinsics(self):
     from human_pose_util.transforms.np_impl import euler_matrix_nh
     from human_pose_util.transforms.np_impl import euler_from_matrix_nh
     # from transformations import euler_from_matrix
     n = 1000
     A = np.random.uniform(size=(n, 3))
     r = np.random.uniform(size=(3, ))
     t = np.random.uniform(-1, 1, size=(3, ))
     R = euler_matrix_nh(r[0], r[1], r[2])
     k = 1.3
     B = k * np.dot(A, R.T) + t
     actual_R, actual_t, actual_k = calculate_extrinsics(A, B)
     np.testing.assert_allclose(actual_R, R)
     np.testing.assert_allclose(actual_t, t)
     np.testing.assert_allclose(actual_k, k)
     actual_r = euler_from_matrix_nh(actual_R)
     np.testing.assert_allclose(actual_r, r)