Flip human joints horizontally. Note: num_keypoints: K Args: joints_3d (np.ndarray([K, 3])): Coordinates of keypoints. joints_3d_visible (np.ndarray([K, 1])): Visibility of keypoints. img_width (int): Image width. flip_pairs (list[tuple()]): Pairs of
(joints_3d, joints_3d_visible, img_width, flip_pairs)
| 10 | |
| 11 | |
| 12 | def fliplr_joints(joints_3d, joints_3d_visible, img_width, flip_pairs): |
| 13 | """Flip human joints horizontally. |
| 14 | |
| 15 | Note: |
| 16 | num_keypoints: K |
| 17 | |
| 18 | Args: |
| 19 | joints_3d (np.ndarray([K, 3])): Coordinates of keypoints. |
| 20 | joints_3d_visible (np.ndarray([K, 1])): Visibility of keypoints. |
| 21 | img_width (int): Image width. |
| 22 | flip_pairs (list[tuple()]): Pairs of keypoints which are mirrored |
| 23 | (for example, left ear -- right ear). |
| 24 | |
| 25 | Returns: |
| 26 | tuple: Flipped human joints. |
| 27 | |
| 28 | - joints_3d_flipped (np.ndarray([K, 3])): Flipped joints. |
| 29 | - joints_3d_visible_flipped (np.ndarray([K, 1])): Joint visibility. |
| 30 | """ |
| 31 | |
| 32 | assert len(joints_3d) == len(joints_3d_visible) |
| 33 | assert img_width > 0 |
| 34 | |
| 35 | joints_3d_flipped = joints_3d.copy() |
| 36 | joints_3d_visible_flipped = joints_3d_visible.copy() |
| 37 | |
| 38 | # Swap left-right parts |
| 39 | for left, right in flip_pairs: |
| 40 | joints_3d_flipped[left, :] = joints_3d[right, :] |
| 41 | joints_3d_flipped[right, :] = joints_3d[left, :] |
| 42 | |
| 43 | joints_3d_visible_flipped[left, :] = joints_3d_visible[right, :] |
| 44 | joints_3d_visible_flipped[right, :] = joints_3d_visible[left, :] |
| 45 | |
| 46 | # Flip horizontally |
| 47 | joints_3d_flipped[:, 0] = img_width - 1 - joints_3d_flipped[:, 0] |
| 48 | joints_3d_flipped = joints_3d_flipped * joints_3d_visible_flipped |
| 49 | |
| 50 | return joints_3d_flipped, joints_3d_visible_flipped |
| 51 | |
| 52 | |
| 53 | def fliplr_regression(regression, |