MCPcopy Create free account
hub / github.com/Pixel-Talk/EHM-Tracker / convert_pose

Method convert_pose

src/modules/pixie/pixie_encoder.py:322–401  ·  view source on GitHub ↗

Convert pose parameters to rotation matrix Args: param_dict: smplx parameters param_type: should be one of body/head/hand Returns: param_dict: smplx parameters

(self, param_dict, param_type)

Source from the content-addressed store, hash-verified

320 return param_dict
321
322 def convert_pose(self, param_dict, param_type):
323 ''' Convert pose parameters to rotation matrix
324 Args:
325 param_dict: smplx parameters
326 param_type: should be one of body/head/hand
327 Returns:
328 param_dict: smplx parameters
329 '''
330 assert param_type in ['body', 'head', 'hand']
331
332 # convert pose representations: the output from network are continous repre or axis angle,
333 # while the input pose for smplx need to be rotation matrix
334 for key in param_dict:
335 if "pose" in key and 'jaw' not in key:
336 param_dict[key] = converter.batch_cont2matrix(param_dict[key])
337 if param_type == 'body' or param_type == 'head':
338 param_dict['jaw_pose'] = converter.batch_euler2matrix(param_dict['jaw_pose'])[
339 :, None, :, :]
340
341 # complement params if it's not in given param dict
342 if param_type == 'head':
343 batch_size = param_dict['shape'].shape[0]
344 param_dict['abs_head_pose'] = param_dict['head_pose'].clone()
345 param_dict['global_pose'] = param_dict['head_pose']
346 param_dict['partbody_pose'] = self.smplx.body_pose.unsqueeze(0).expand(
347 batch_size, -1, -1, -1)[:, :self.param_list_dict['body_list']['partbody_pose']]
348 param_dict['neck_pose'] = self.smplx.neck_pose.unsqueeze(
349 0).expand(batch_size, -1, -1, -1)
350 param_dict['left_wrist_pose'] = self.smplx.neck_pose.unsqueeze(
351 0).expand(batch_size, -1, -1, -1)
352 param_dict['left_hand_pose'] = self.smplx.left_hand_pose.unsqueeze(
353 0).expand(batch_size, -1, -1, -1)
354 param_dict['right_wrist_pose'] = self.smplx.neck_pose.unsqueeze(
355 0).expand(batch_size, -1, -1, -1)
356 param_dict['right_hand_pose'] = self.smplx.right_hand_pose.unsqueeze(
357 0).expand(batch_size, -1, -1, -1)
358 elif param_type == 'hand':
359 batch_size = param_dict['right_hand_pose'].shape[0]
360 param_dict['abs_right_wrist_pose'] = param_dict['right_wrist_pose'].clone()
361 dtype = param_dict['right_hand_pose'].dtype
362 device = param_dict['right_hand_pose'].device
363 x_180_pose = torch.eye(
364 3, dtype=dtype, device=device).unsqueeze(0).repeat(1, 1, 1)
365 x_180_pose[0, 2, 2] = -1.
366 x_180_pose[0, 1, 1] = -1.
367 param_dict['global_pose'] = x_180_pose.unsqueeze(
368 0).expand(batch_size, -1, -1, -1)
369 param_dict['shape'] = self.smplx.shape_params.expand(
370 batch_size, -1)
371 param_dict['exp'] = self.smplx.expression_params.expand(
372 batch_size, -1)
373 param_dict['head_pose'] = self.smplx.head_pose.unsqueeze(
374 0).expand(batch_size, -1, -1, -1)
375 param_dict['neck_pose'] = self.smplx.neck_pose.unsqueeze(
376 0).expand(batch_size, -1, -1, -1)
377 param_dict['jaw_pose'] = self.smplx.jaw_pose.unsqueeze(
378 0).expand(batch_size, -1, -1, -1)
379 param_dict['partbody_pose'] = self.smplx.body_pose.unsqueeze(0).expand(

Callers 1

decodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected