MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / canonicalize_motion

Function canonicalize_motion

motion_rep/retarget_motion.py:168–184  ·  view source on GitHub ↗
(smpl_params, joints, set_floor=False)

Source from the content-addressed store, hash-verified

166 return smpl_params
167
168def canonicalize_motion(smpl_params, joints, set_floor=False):
169 # Get transformation and update smpl_params
170 R_inv = get_transform_DART(joints)
171 aligned_smpl_params = apply_rotation(smpl_params, R_inv)
172 joints_base = torch.matmul(R_inv[None, None, :, :], joints.unsqueeze(-1)).squeeze(-1)
173
174 delta_transl = -joints_base[0, 0:1] # fetch the pelvis joint from first frame, Shape: (1,3)
175 if set_floor:
176 # For gravity axis (Z), set the minimum z-coordinate to 0 as the floor
177 delta_transl[0, 2] = - torch.min(joints_base[..., 2])
178 joints = joints_base + delta_transl[None,]
179 aligned_smpl_params['transl'] += delta_transl
180
181 # Convert to motion representation
182 motion = collect_motion_rep_DART(aligned_smpl_params, joints) # 276-dim representation
183
184 return motion, joints[:-1], R_inv, delta_transl
185
186def process_hmr_motion(hmr_motion, intrinsic, to_cpu=True, set_floor=False):
187 new_data = {}

Callers 1

process_hmr_motionFunction · 0.85

Calls 3

get_transform_DARTFunction · 0.85
apply_rotationFunction · 0.85
collect_motion_rep_DARTFunction · 0.85

Tested by

no test coverage detected