Esempio n. 1
0
 def test_frame_iteration(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     x_accumulator = 0.0
     for i in range(0, mocap.nframes):
         x_accumulator += mocap.frame_joint_channel(i, 'Hips', 'Xposition')
     self.assertTrue(abs(-19735.902699999995 - x_accumulator) < 0.0001)
Esempio n. 2
0
 def test_channels(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.joint_channels('LeftElbow'),
                      ['Zrotation', 'Xrotation', 'Yrotation'])
     self.assertEqual(mocap.joint_channels('Hips'), [
         'Xposition', 'Yposition', 'Zposition', 'Zrotation', 'Xrotation',
         'Yrotation'
     ])
Esempio n. 3
0
 def test_tree2(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual([str(item) for item in mocap.root], [
         'HIERARCHY', 'ROOT Hips', 'MOTION', 'Frames: 455',
         'Frame Time: 0.033333'
     ])
Esempio n. 4
0
 def test_joint_children(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(
         mocap.joint_direct_children('Chest')[0].name, 'Chest2')
     self.assertEqual(mocap.joint_direct_children('Hips')[0].name, 'Chest')
     self.assertEqual(
         mocap.joint_direct_children('Hips')[1].name, 'LeftHip')
     self.assertEqual(
         mocap.joint_direct_children('Hips')[2].name, 'RightHip')
     self.assertEqual(mocap.joint_direct_children('RightWrist'), [])
Esempio n. 5
0
    def test_bones(self):
        bones = []
        with open('tests/example_files/test_freebvh.bvh') as f:
            mocap = Bvh(f.read())

        def iterate_joints(joint):
            bones.append(str(joint))
            for child in joint.filter('JOINT'):
                iterate_joints(child)

        iterate_joints(next(mocap.root.filter('ROOT')))
        self.assertEqual(bones[0], 'ROOT mixamorig:Hips')
        self.assertEqual(bones[17], 'JOINT mixamorig:LeftHandThumb2')
        self.assertEqual(bones[22], 'JOINT mixamorig:LeftHandRing1')
        self.assertEqual(bones[30], 'JOINT mixamorig:RightForeArm')
Esempio n. 6
0
 def test_frame_channel(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.frame_joint_channel(22, 'Hips', 'Xrotation'),
                      -20.98)
     self.assertEqual(mocap.frame_joint_channel(22, 'Chest', 'Xrotation'),
                      17.65)
     self.assertEqual(mocap.frame_joint_channel(22, 'Neck', 'Xrotation'),
                      -6.77)
     self.assertEqual(mocap.frame_joint_channel(22, 'Head', 'Yrotation'),
                      8.47)
Esempio n. 7
0
 def test_unknown_attribute(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     with self.assertRaises(IndexError):
         mocap.root['Broken']
Esempio n. 8
0
 def test_empty_root(self):
     mocap = Bvh('')
     self.assertTrue(isinstance(mocap.root, BvhNode))
Esempio n. 9
0
 def test_file_read(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(len(mocap.data), 98838)
Esempio n. 10
0
 def test_nframes_red_light(self):
     mocap = Bvh('')
     with self.assertRaises(LookupError):
         mocap.nframes
Esempio n. 11
0
 def test_frames_multi_channels(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     rotations = mocap.frames_joint_channels(
         'Head', ['Xrotation', 'Yrotation', 'Zrotation'])
     self.assertEqual(len(rotations), mocap.nframes)
Esempio n. 12
0
 def test_frame_joint_multi_channels(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     rotation = mocap.frame_joint_channels(
         30, 'Head', ['Xrotation', 'Yrotation', 'Zrotation'])
     self.assertEqual(rotation, [1.77, 13.94, -7.42])
Esempio n. 13
0
 def test_nframes2(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.nframes, 455)
Esempio n. 14
0
 def test_unknown_joint(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     with self.assertRaises(LookupError):
         mocap.joint_offset('FooBar')
Esempio n. 15
0
 def test_search_single_item(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual([str(node) for node in mocap.search('ROOT')],
                      ['ROOT Hips'])
Esempio n. 16
0
 def test_offset(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(
         next(mocap.root.filter('ROOT'))['OFFSET'],
         ['0.0000', '0.0000', '0.0000'])
Esempio n. 17
0
 def test_frame_channel2(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(
         mocap.frame_joint_channel(22, 'mixamorig:Hips', 'Xposition'),
         4.3314)
Esempio n. 18
0
 def test_nframes(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.nframes, 69)
Esempio n. 19
0
 def test_nframes_with_frames_list(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.nframes, len(mocap.frames))
Esempio n. 20
0
 def test_filter(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual([str(item) for item in mocap.root.filter('ROOT')],
                      ['ROOT mixamorig:Hips'])
Esempio n. 21
0
 def test_joint_parent(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.joint_parent('Chest').name, 'Hips')
Esempio n. 22
0
 def test_joints_names(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.get_joints_names()[17], 'RightKnee')
Esempio n. 23
0
 def test_frame_time(self):
     with open('tests/example_files/test_freebvh.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.frame_time, 0.0333333)
Esempio n. 24
0
 def test_search(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(
         [str(node) for node in mocap.search('JOINT', 'LeftShoulder')],
         ['JOINT LeftShoulder'])
Esempio n. 25
0
 def test_joint_parent_index(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.joint_parent_index('Hips'), -1)
     self.assertEqual(mocap.joint_parent_index('Chest'), 0)
     self.assertEqual(mocap.joint_parent_index('LeftShoulder'), 3)
Esempio n. 26
0
 def test_search_single_item_joints(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(len(mocap.search('JOINT')), 18)
Esempio n. 27
0
 def test_joint_offset(self):
     with open('tests/example_files/test_mocapbank.bvh') as f:
         mocap = Bvh(f.read())
     self.assertEqual(mocap.joint_offset('RightElbow'),
                      (-2.6865, -25.0857, 1.2959))