示例#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)
示例#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'
     ])
示例#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'
     ])
示例#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'), [])
示例#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')
示例#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)
示例#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']
示例#8
0
 def test_empty_root(self):
     mocap = Bvh('')
     self.assertTrue(isinstance(mocap.root, BvhNode))
示例#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)
示例#10
0
 def test_nframes_red_light(self):
     mocap = Bvh('')
     with self.assertRaises(LookupError):
         mocap.nframes
示例#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)
示例#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])
示例#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)
示例#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')
示例#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'])
示例#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'])
示例#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)
示例#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)
示例#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))
示例#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'])
示例#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')
示例#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')
示例#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)
示例#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'])
示例#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)
示例#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)
示例#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))