def retarget_motion_in_db(db_url,
                          retargeting,
                          motion_id,
                          motion_name,
                          collection,
                          skeleton_model_name,
                          is_aligned=False,
                          session=None):
    motion_data = get_motion_by_id_from_remote_db(db_url,
                                                  motion_id,
                                                  is_processed=is_aligned)
    if motion_data is None:
        print("Error: motion data is empty")
        return

    meta_info_str = get_annotation_by_id_from_remote_db(
        db_url, motion_id, is_processed=is_aligned)
    motion_vector = MotionVector()
    motion_vector.from_custom_db_format(motion_data)
    motion_vector.skeleton = retargeting.src_skeleton
    new_frames = retargeting.run(motion_vector.frames, frame_range=None)
    target_motion = MotionVector()
    target_motion.frames = new_frames
    target_motion.skeleton = retargeting.target_skeleton
    target_motion.frame_time = motion_vector.frame_time
    target_motion.n_frames = len(new_frames)
    m_data = target_motion.to_db_format()
    upload_motion_to_db(db_url,
                        motion_name,
                        m_data,
                        collection,
                        skeleton_model_name,
                        meta_info_str,
                        is_processed=is_aligned,
                        session=session)
Exemple #2
0
 def get_motion_vector_copy(self, start_frame, end_frame, sample_idx=0):
     if sample_idx < len(self.samples):
         mv_copy = MotionVector()
         mv_copy.frames = deepcopy(self.samples[0].frames[start_frame:end_frame])
         mv_copy.frames = self.skeleton.add_fixed_joint_parameters_to_motion(mv_copy.frames)
         mv_copy.n_frames = len(mv_copy.frames)
         mv_copy.frame_time = self.frameTime
         return mv_copy
 def get_motion_vector_copy(self, start_frame, end_frame):
     mv_copy = MotionVector()
     mv_copy.frames = deepcopy(self._motion.frames[start_frame:end_frame])
     skeleton = self._graph.skeleton
     mv_copy.frames = skeleton.add_fixed_joint_parameters_to_motion(
         mv_copy.frames)
     mv_copy.n_frames = len(mv_copy.frames)
     mv_copy.frame_time = self.frameTime
     return mv_copy
Exemple #4
0
 def get_motion_vector_copy(self, start_frame=0, end_frame=-1):
     mv_copy = MotionVector()
     if end_frame > 0:
         mv_copy.frames = deepcopy(
             self._motion.mv.frames[start_frame:end_frame])
     else:
         mv_copy.frames = np.array(self._motion.mv.frames)
     mv_copy.n_frames = len(mv_copy.frames)
     mv_copy.frame_time = self._motion.mv.frame_time
     return mv_copy
Exemple #5
0
                        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)