Draw a hand skeleton.
(ax, hand_positions: dict[str, np.ndarray], color: str, label: str)
| 160 | |
| 161 | |
| 162 | def draw_hand(ax, hand_positions: dict[str, np.ndarray], color: str, label: str): |
| 163 | """Draw a hand skeleton.""" |
| 164 | if not hand_positions: |
| 165 | return |
| 166 | |
| 167 | # Swap Y/Z for all positions |
| 168 | swapped_positions = {k: swap_yz(v) for k, v in hand_positions.items()} |
| 169 | |
| 170 | # Draw joints |
| 171 | positions = np.array(list(swapped_positions.values())) |
| 172 | ax.scatter(positions[:, 0], positions[:, 1], positions[:, 2], |
| 173 | c=color, s=20, alpha=0.8, label=label) |
| 174 | |
| 175 | # Draw connections |
| 176 | for joint1, joint2 in HAND_CONNECTIONS: |
| 177 | if joint1 in swapped_positions and joint2 in swapped_positions: |
| 178 | p1 = swapped_positions[joint1] |
| 179 | p2 = swapped_positions[joint2] |
| 180 | ax.plot([p1[0], p2[0]], [p1[1], p2[1]], [p1[2], p2[2]], |
| 181 | color=color, linewidth=1.5, alpha=0.7) |
| 182 | |
| 183 | |
| 184 | def draw_camera_frame(ax, head_matrix: np.ndarray, extrinsic: dict | None, scale: float = 0.08): |