Rotate SMPL pose parameters. SMPL (https://smpl.is.tue.mpg.de/) is a 3D human model. Args: pose (np.ndarray([72])): SMPL pose parameters rot (float): Rotation angle (degree). Returns: pose_rotated
(pose, rot)
| 319 | |
| 320 | |
| 321 | def _rotate_smpl_pose(pose, rot): |
| 322 | """Rotate SMPL pose parameters. |
| 323 | |
| 324 | SMPL (https://smpl.is.tue.mpg.de/) is a 3D |
| 325 | human model. |
| 326 | Args: |
| 327 | pose (np.ndarray([72])): SMPL pose parameters |
| 328 | rot (float): Rotation angle (degree). |
| 329 | Returns: |
| 330 | pose_rotated |
| 331 | """ |
| 332 | pose_rotated = pose.copy() |
| 333 | if rot != 0: |
| 334 | # rot_mat = _construct_rotation_matrix(-rot) |
| 335 | # orient = pose[:3] |
| 336 | # # find the rotation of the body in camera frame |
| 337 | # per_rdg, _ = cv2.Rodrigues(orient.astype(np.float32)) |
| 338 | # # apply the global rotation to the global orientation |
| 339 | # res_rot, _ = cv2.Rodrigues(np.dot(rot_mat, per_rdg)) |
| 340 | # pose_rotated[:3] = (res_rot.T)[0] |
| 341 | |
| 342 | # use pytorch3d |
| 343 | rot_mat = _construct_rotation_matrix(-rot) |
| 344 | orient = pose[..., :3] |
| 345 | per_rdg = aa_to_rotmat(orient) |
| 346 | |
| 347 | if pose.ndim == 1: |
| 348 | tmp_rot = np.einsum('ij,jk->ik', rot_mat, per_rdg) |
| 349 | elif pose.ndim == 2: |
| 350 | tmp_rot = np.einsum('ij,mjk->mik', rot_mat, per_rdg) |
| 351 | else: |
| 352 | msg = f'Expected pose to have ndim of 2 or 3, but get {pose.ndim} ' |
| 353 | raise ValueError(msg) |
| 354 | |
| 355 | res_rot = rotmat_to_aa(tmp_rot) |
| 356 | pose_rotated[..., :3] = res_rot |
| 357 | |
| 358 | # use cv2 |
| 359 | # rot_mat = _construct_rotation_matrix(-rot) |
| 360 | # for i in range(pose.shape[0]): |
| 361 | # orient = pose[i, :3] |
| 362 | # # find the rotation of the body in camera frame |
| 363 | # per_rdg, _ = cv2.Rodrigues(orient.astype(np.float32)) |
| 364 | # # apply the global rotation to the global orientation |
| 365 | # res_rot, _ = cv2.Rodrigues(np.dot(rot_mat, per_rdg)) |
| 366 | # pose_rotated[i, :3] = (res_rot.T)[0] |
| 367 | |
| 368 | return pose_rotated |
| 369 | |
| 370 | |
| 371 | def _bbox_flip(bboxes, img_shape, direction): |
no test coverage detected