Get SMPL (world coordinate) computed by mocap processing pipeline. Args: Frame_id (int, list or None, optional): int: frame id of one selected frame list: a list of frame id None: all frames will be returned Default
(self, Frame_id=None)
| 348 | |
| 349 | ###SMPLx |
| 350 | def get_SMPLx(self, Frame_id=None): |
| 351 | """Get SMPL (world coordinate) computed by mocap processing pipeline. |
| 352 | |
| 353 | Args: |
| 354 | Frame_id (int, list or None, optional): |
| 355 | int: frame id of one selected frame |
| 356 | list: a list of frame id |
| 357 | None: all frames will be returned |
| 358 | Defaults to None. |
| 359 | |
| 360 | Returns: |
| 361 | dict: |
| 362 | 'global_orient': np.ndarray of shape (N, 3) |
| 363 | 'body_pose': np.ndarray of shape (N, 21, 3) |
| 364 | 'transl': np.ndarray of shape (N, 3) |
| 365 | 'betas': np.ndarray of shape (1, 10) |
| 366 | """ |
| 367 | if not 'SMPLx' in self.smc: |
| 368 | print("=== no key: SMPLx.\nplease check available keys!") |
| 369 | return None |
| 370 | |
| 371 | t_frame = self.smc['SMPLx']['betas'][()].shape[0] |
| 372 | print("=== t_frame", self.smc['SMPLx']['betas'][()].shape, flush=True) |
| 373 | |
| 374 | key_arr = ['betas', 'expression', 'fullpose', 'transl'] |
| 375 | for k in key_arr: |
| 376 | print("=== smplx %s" % k, self.smc['SMPLx'][k][()].shape[0], flush=True) |
| 377 | |
| 378 | if Frame_id is None: |
| 379 | frame_list = range(t_frame) |
| 380 | elif isinstance(Frame_id, list): |
| 381 | frame_list = [int(fi) for fi in Frame_id] |
| 382 | elif isinstance(Frame_id, (int,str)): |
| 383 | Frame_id = int(Frame_id) |
| 384 | assert Frame_id < t_frame,\ |
| 385 | f'Invalid frame_index {Frame_id}' |
| 386 | frame_list = Frame_id |
| 387 | else: |
| 388 | raise TypeError('frame_id should be int, list or None.') |
| 389 | |
| 390 | smpl_dict = {} |
| 391 | for key in ['betas', 'expression', 'fullpose', 'transl']: |
| 392 | smpl_dict[key] = self.smc['SMPLx'][key][()][frame_list, ...] |
| 393 | smpl_dict['scale'] = self.smc['SMPLx']['scale'][()] |
| 394 | |
| 395 | return smpl_dict |
| 396 | |
| 397 | def release(self): |
| 398 | self.smc = None |
no outgoing calls
no test coverage detected