def test_bvh_load_frame2(self): file_path = '%s/0007_Cartwheel001.bvh' % BVH_DIR self.root, self.frames, self.frame_time = BVH.load(file_path) assert (len(self.frames) == 2111) assert (self.frame_time == 0.008333) for frame in self.frames: self.root.load_frame(frame) self.root.apply_transformation() TestCase.check_bvh_node_distance_against_parent(self.root) TestCase.check_bvh_node_above_ground(self.root)
def test_bvh_load_frame(self): file_path = '%s/rotate_hip.bvh' % BVH_DIR self.root, self.frames, self.frame_time = BVH.load(file_path) assert (len(self.frames) == 15) assert (self.frame_time == 1.8333) for frame in self.frames[0:1]: self.root.load_frame(frame) self.root.apply_transformation() print(self.root.str(True)) TestCase.check_bvh_node_distance_against_parent(self.root)
def play_file(self, file_path, test): ''' If test is true, after finish the playback, quit the application ''' self.is_test_run = test self.SetStatusText('Showing %s. Mouse left button to rotate, ' 'mouse right button to move, ' 'mouse wheel to zoom' % os.path.basename(file_path)) self.root, self.frames, self.frame_time = BVH.load(file_path) if self.is_test_run: self.frames = self.frames[:100] self.frame_i = 0 self.playback_panel.set_slider_range(1, len(self.frames)) self.worker_thread.set_interval(self.frame_time)
def test_bvh_node_distance(self): file_path = '%s/0007_Cartwheel001.bvh' % BVH_DIR self.root, self.frames, self.frame_time = BVH.load(file_path) root2 = copy.deepcopy(self.root) self.root.load_frame(self.frames[0]) self.root.apply_transformation() root2.load_frame(self.frames[0]) root2.apply_transformation() assert (BVH.BVHNode.distance(self.root, root2) == 0) root2.load_frame(self.frames[1]) root2.apply_transformation() assert (BVH.BVHNode.distance(self.root, root2) > 0) assert (BVH.BVHNode.distance(self.root, root2) == self.root.frame_distance( self.frames[0], self.frames[1])) TestCase.set_all_weight_0(self.root) TestCase.set_all_weight_0(root2) assert (BVH.BVHNode.distance(self.root, root2) == 0)
ax.plot3D(zline, xline, yline, 'gray') def visualize(root): """ Visualize a given frame of the motion :param root: root of the BVH structure :return: nothing, will create 3D plot for this frame """ ax = plt.axes(projection='3d') show_frame(root, ax) plt.show() if __name__ == '__main__': file_path = 'tests/bvh_files/0007_Cartwheel001.bvh' root, frames, frame_time = BVH.load(file_path) print('number of frames = %d' % len(frames)) # "number of frames = 2111" for fr in range(len(frames)): root.load_frame(frames[fr]) root.apply_transformation() # Visualize the frame visualize(root)
def test_bvh_node_search(self): file_path = '%s/0007_Cartwheel001.bvh' % BVH_DIR self.root, self.frames, self.frame_time = BVH.load(file_path) assert (self.root.search_node('Head') != None)
def test_bvh_parse(self): file_path = '%s/0007_Cartwheel001.bvh' % BVH_DIR self.root, self.frames, self.frame_time = BVH.load(file_path) assert (len(self.frames) == 2111) assert (self.frame_time == 0.008333)