def export_frames_to_bvh(skeleton, frames, filename): print("export", len(frames[0])) mv = MotionVector() mv.frames = np.array( [skeleton.add_fixed_joint_parameters_to_frame(f) for f in frames]) print(mv.frames.shape) mv.export(skeleton, filename, add_time_stamp=False)
def export(self, output_filename, add_time_stamp=False, export_details=False): """ Saves the resulting animation frames, the annotation and actions to files. Also exports the input file again to the output directory, where it is used as input for the constraints visualization by the animation server. """ MotionVector.export(self, self.skeleton, output_filename, add_time_stamp) self.export_annotation(output_filename)
nargs='?', help='skeleton model name') parser.add_argument('src_motion', nargs='?', help='bvh filename') parser.add_argument('src_skeleton_type', nargs='?', help='skeleton model name') parser.add_argument('out_filename', nargs='?', help='filename') parser.add_argument('src_scale', nargs='?', default=1.0, help='float') parser.add_argument('place_on_ground', nargs='?', default=1, help='int') args = parser.parse_args() if args.src_motion is not None and args.dest_skeleton is not None and args.out_filename is not None: src_skeleton, src_motion = load_motion(args.src_motion, args.src_skeleton_type) dest_skeleton = load_skeleton(args.dest_skeleton, args.dest_skeleton_type) joint_map = generate_joint_map(src_skeleton.skeleton_model, dest_skeleton.skeleton_model) retargeting = Retargeting(src_skeleton, dest_skeleton, joint_map, float(args.src_scale), additional_rotation_map=None, place_on_ground=bool(args.place_on_ground)) new_frames = retargeting.run(src_motion.frames, frame_range=None) target_motion = MotionVector() target_motion.frames = new_frames target_motion.skeleton = retargeting.target_skeleton target_motion.frame_time = src_motion.frame_time target_motion.n_frames = len(new_frames) target_motion.export(dest_skeleton, args.out_filename)