Rotate the 3D joints in the local coordinates. Notes: Joints number: K Args: joints_3d (np.ndarray([K, 3])): Coordinates of keypoints. rot (float): Rotation angle (degree). Returns: joints_3d_rotated
(joints_3d, rot)
| 292 | |
| 293 | |
| 294 | def _rotate_joints_3d(joints_3d, rot): |
| 295 | """Rotate the 3D joints in the local coordinates. |
| 296 | |
| 297 | Notes: |
| 298 | Joints number: K |
| 299 | Args: |
| 300 | joints_3d (np.ndarray([K, 3])): Coordinates of keypoints. |
| 301 | rot (float): Rotation angle (degree). |
| 302 | Returns: |
| 303 | joints_3d_rotated |
| 304 | """ |
| 305 | # in-plane rotation |
| 306 | # 3D joints are rotated counterclockwise, |
| 307 | # so the rot angle is inversed. |
| 308 | rot_mat = _construct_rotation_matrix(-rot, 3) |
| 309 | if joints_3d.ndim == 2: |
| 310 | joints_3d_rotated = np.einsum('ij,kj->ki', rot_mat, joints_3d) |
| 311 | elif joints_3d.ndim == 3: |
| 312 | joints_3d_rotated = np.einsum('ij,mkj->mki', rot_mat, joints_3d) |
| 313 | else: |
| 314 | msg = 'Expected joints_3d to have ndim of 2 or 3, ' |
| 315 | f'but get {joints_3d.ndim}.' |
| 316 | raise ValueError(msg) |
| 317 | joints_3d_rotated = joints_3d_rotated.astype('float32') |
| 318 | return joints_3d_rotated |
| 319 | |
| 320 | |
| 321 | def _rotate_smpl_pose(pose, rot): |
no test coverage detected