Exemplo n.º 1
0
 def test_size(self):
     m = {
         0: scap(),
         1: scap(),
         5: scap()
     }
     cm = CameraMap(m)
     nose.tools.assert_equal(cm.size, 3)
Exemplo n.º 2
0
 def test_as_dict(self):
     m = {
         0: scap(),
         1: scap(),
         5: scap()
     }
     cm = CameraMap(m)
     m2 = cm.as_dict()
     nose.tools.assert_equal(m[0].image_width(), m2[0].image_width())
Exemplo n.º 3
0
 def test_methods(self):
     a1 = scap()
     a2 = scap()
     cam_dict = {1:a1, 2:a2}
     a = CameraPerspectiveInheritance(cam_dict)
     ret_size = cpmh.call_size(a)
     self.assertEqual(ret_size, 2)
     ret_cam_dict = cpmh.call_cameras(a)
     self.assertDictEqual(ret_cam_dict, cam_dict)
     a = CameraPerspectiveInheritance(cam_dict)
     ret_set = cpmh.call_get_frame_ids(a)
     self.assertSetEqual(ret_set, {1,2})
 def test_overridden(self):
     a = scap(center=self.vec, rotation=self.rot, intrinsics=self.intrins)
     clone_ = cph.call_clone(a)
     self.assertIsInstance(clone_, scap)
     np.testing.assert_array_equal(clone_.get_center(), self.vec)
     center_ = cph.call_center(a)
     np.testing.assert_array_equal(center_, self.vec)
     trans_ = cph.call_translation(a)
     np.testing.assert_array_equal(
         trans_, -(a.get_rotation().inverse() * a.get_center()))
     covar_ = cph.call_center_covar(a)
     self.assertIsInstance(covar_, Covar3d)
     np.testing.assert_array_equal(
         covar_.matrix(), np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]))
     rot_ = cph.call_rotation(a)
     nt.assert_equal(rot_, self.rot)
     intr_ = cph.call_intrinsics(a)
     nt.assert_equal(intr_, self.intrins)
     ih_ = cph.call_image_height(a)
     self.assertEqual(ih_, 720)
     iw_ = cph.call_image_width(a)
     self.assertEqual(iw_, 1080)
     clone_look_at_ = cph.call_clone_look_at(a, np.array([1, 0, 0]),
                                             np.array([0, 1, 0]))
     self.assertIsInstance(clone_look_at_, scap)
     nt.assert_not_equal(clone_look_at_.get_rotation(), self.rot)
     cam_ = cph.call_as_matrix(a)
     np.testing.assert_array_almost_equal(
         cam_,
         np.array([[10.5, 3.1, 3.14, -69.5378], [0, 8.75, 6.28, -63.0826],
                   [0, 0, 1, -5.67]]))
    def test_not_overidden(self):
        # Test getters
        scap_ = scap(center=self.vec,
                     rotation=self.rot,
                     intrinsics=self.intrins)
        np.testing.assert_array_equal(scap_.get_center(), self.vec)
        self.assertIsInstance(scap_.get_rotation(), RotationD)
        nt.assert_equal(scap_.get_rotation(), self.rot)
        self.assertIsInstance(scap_.get_intrinsics(), ci)
        nt.assert_equal(scap_.get_intrinsics(), self.intrins)

        # Test setters
        new_center = np.array([0, 2, 0])
        scap_.set_center(new_center)
        np.testing.assert_array_equal(scap_.get_center(), new_center)
        new_rot = RotationD(1, np.array([0, 2, 0]))
        scap_.set_rotation(new_rot)
        nt.assert_equal(scap_.get_rotation(), new_rot)
        scap_.set_intrinsics(self.intrins_empty)
        nt.assert_equal(scap_.get_intrinsics(), self.intrins_empty)
        scap_.set_translation(np.array([1, 0, 3]))
        np.testing.assert_array_equal(
            scap_.get_center(),
            -(scap_.get_rotation().inverse() * np.array([1, 0, 3])))

        # Test covar setter/gettter
        m_out = self.covar3d.matrix()
        scap_.set_center_covar(self.covar3d)
        np.testing.assert_array_equal(scap_.get_center_covar().matrix(), m_out)

        # Test other (look_at)
        scap_ = scap()
        scap_.look_at(np.array([1, 0, 0]), np.array([0, 0, 1]))
        rot_ = scap_.get_rotation()
        np.testing.assert_array_almost_equal(
            rot_.matrix(), np.array([[0, -1, 0], [0, 0, -1], [1, 0, 0]]))
Exemplo n.º 6
0
 def test_constructors(self):
     cam()
     a = scap()
     b = {1:a}
     cam(b)
Exemplo n.º 7
0
 def setUp(self):
     self.a = scap()
     self.a2 = scap()
     self.a3 = scap()
     self.b = {1:self.a,2:self.a2,3:self.a3}
     self.ca = cam(self.b)
Exemplo n.º 8
0
 def test_inheritance(self):
     a1 = scap()
     a2 = scap()
     cam_dct = {1:a1, 2:a2}
     CameraPerspectiveInheritance(cam_dct)
     nt.ok_(issubclass(CameraPerspectiveInheritance, cam))
Exemplo n.º 9
0
 def test_construct(self):
     a1 = scap()
     a2 = scap()
     cam_dict = {1:a1, 2:a2}
     CameraPerspectiveInheritance(cam_dict)
 def test_construct(self):
     scap()
     scap(center=self.vec, rotation=self.rot, intrinsics=self.intrins)
     scap(center=self.vec, rotation=self.rot)
     scap(scap())