MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / process_file

Function process_file

mGPT/data/humanml/scripts/motion_process.py:169–351  ·  view source on GitHub ↗

Uniform Skeleton

(positions, feet_thre)

Source from the content-addressed store, hash-verified

167
168
169def process_file(positions, feet_thre):
170 # (seq_len, joints_num, 3)
171 # '''Down Sample'''
172 # positions = positions[::ds_num]
173
174 '''Uniform Skeleton'''
175 positions = uniform_skeleton(positions, tgt_offsets)
176
177 '''Put on Floor'''
178 floor_height = positions.min(axis=0).min(axis=0)[1]
179 positions[:, :, 1] -= floor_height
180 # print(floor_height)
181
182 # plot_3d_motion("./positions_1.mp4", kinematic_chain, positions, 'title', fps=20)
183
184 '''XZ at origin'''
185 root_pos_init = positions[0]
186 root_pose_init_xz = root_pos_init[0] * np.array([1, 0, 1])
187 positions = positions - root_pose_init_xz
188
189 # '''Move the first pose to origin '''
190 # root_pos_init = positions[0]
191 # positions = positions - root_pos_init[0]
192
193 '''All initially face Z+'''
194 r_hip, l_hip, sdr_r, sdr_l = face_joint_indx
195 across1 = root_pos_init[r_hip] - root_pos_init[l_hip]
196 across2 = root_pos_init[sdr_r] - root_pos_init[sdr_l]
197 across = across1 + across2
198 across = across / np.sqrt((across ** 2).sum(axis=-1))[..., np.newaxis]
199
200 # forward (3,), rotate around y-axis
201 forward_init = np.cross(np.array([[0, 1, 0]]), across, axis=-1)
202 # forward (3,)
203 forward_init = forward_init / np.sqrt((forward_init ** 2).sum(axis=-1))[..., np.newaxis]
204
205 # print(forward_init)
206
207 target = np.array([[0, 0, 1]])
208 root_quat_init = qbetween_np(forward_init, target)
209 root_quat_init = np.ones(positions.shape[:-1] + (4,)) * root_quat_init
210
211 positions_b = positions.copy()
212
213 positions = qrot_np(root_quat_init, positions)
214
215 # plot_3d_motion("./positions_2.mp4", kinematic_chain, positions, 'title', fps=20)
216
217 '''New ground truth positions'''
218 global_positions = positions.copy()
219
220 # plt.plot(positions_b[:, 0, 0], positions_b[:, 0, 2], marker='*')
221 # plt.plot(positions[:, 0, 0], positions[:, 0, 2], marker='o', color='r')
222 # plt.xlabel('x')
223 # plt.ylabel('z')
224 # plt.axis('equal')
225 # plt.show()
226

Callers 3

joints2featsMethod · 0.85
joints2featsMethod · 0.85
motion_process.pyFile · 0.85

Calls 6

uniform_skeletonFunction · 0.85
qbetween_npFunction · 0.85
qrot_npFunction · 0.85
foot_detectFunction · 0.85
get_cont6d_paramsFunction · 0.85
get_rifkeFunction · 0.85

Tested by

no test coverage detected