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

Function process_poses

scripts/fbx_output_smplx.py:217–303  ·  view source on GitHub ↗
(
        input_path,
        gender,
        fps_source,
        fps_target,
        start_origin,
        person_id=1,
)

Source from the content-addressed store, hash-verified

215
216# Process all the poses from the pose file
217def process_poses(
218 input_path,
219 gender,
220 fps_source,
221 fps_target,
222 start_origin,
223 person_id=1,
224):
225
226 print('Processing: ' + input_path)
227
228 smpl_params = joblib.load(input_path)
229 poses, lhposes, rhposes = [], [], []
230 for iframe in smpl_params.keys():
231 poses.append(smpl_params[iframe]['rot'])
232 lhposes.append(smpl_params[iframe]['hand_quaternions'][4:64].copy().reshape(-1, 4))
233 rhposes.append(smpl_params[iframe]['hand_quaternions'][68:128].copy().reshape(-1, 4))
234 poses = np.vstack(poses)
235 lhposes = np.stack(lhposes)
236 rhposes = np.stack(rhposes)
237
238 trans = np.zeros((poses.shape[0], 3))
239 # if 'trans' not in data[person_id].keys():
240 # trans = np.zeros((poses.shape[0], 3))
241 # else:
242 # trans = data[person_id]['trans']
243
244 model_path = neural_smplx_path
245 # if gender == 'female':
246 # model_path = female_model_path
247 # for k,v in BODY_JOINT_NAMES.items():
248 # BODY_JOINT_NAMES[k] = 'f_avg_' + v
249 # elif gender == 'male':
250 # model_path = male_model_path
251 # for k,v in BODY_JOINT_NAMES.items():
252 # BODY_JOINT_NAMES[k] = 'm_avg_' + v
253 # else:
254 # print('ERROR: Unsupported gender: ' + gender)
255 # sys.exit(1)
256
257 # Limit target fps to source fps
258 if fps_target > fps_source:
259 fps_target = fps_source
260
261 print(f'Gender: {gender}')
262 print(f'Number of source poses: {str(poses.shape[0])}')
263 print(f'Source frames-per-second: {str(fps_source)}')
264 print(f'Target frames-per-second: {str(fps_target)}')
265 print('--------------------------------------------------')
266
267 setup_scene(model_path, fps_target)
268
269 scene = bpy.data.scenes['Scene']
270 sample_rate = int(fps_source/fps_target)
271 scene.frame_end = (int)(poses.shape[0]/sample_rate)
272
273 # Retrieve pelvis world position.
274 # Unit is [cm] due to Armature scaling.

Callers 1

Calls 3

keysMethod · 0.80
setup_sceneFunction · 0.70
process_poseFunction · 0.70

Tested by

no test coverage detected