Spaces:
Sleeping
Sleeping
Niharmahesh
commited on
Commit
•
ec7574f
1
Parent(s):
37c7634
Delete visualization.py
Browse files- visualization.py +0 -26
visualization.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
import matplotlib.pyplot as plt
|
2 |
-
import mediapipe as mp
|
3 |
-
|
4 |
-
def plot_hand_landmarks(landmarks, title):
|
5 |
-
"""
|
6 |
-
Plot hand landmarks on a figure.
|
7 |
-
|
8 |
-
Parameters:
|
9 |
-
landmarks (numpy.ndarray): Array of hand landmarks.
|
10 |
-
title (str): Title of the plot.
|
11 |
-
|
12 |
-
Returns:
|
13 |
-
matplotlib.figure.Figure: The plotted figure.
|
14 |
-
"""
|
15 |
-
fig, ax = plt.subplots(figsize=(5, 5))
|
16 |
-
ax.scatter(landmarks[:, 0], landmarks[:, 1], c='blue', s=20)
|
17 |
-
mp_hands = mp.solutions.hands
|
18 |
-
for connection in mp_hands.HAND_CONNECTIONS:
|
19 |
-
start_idx = connection[0]
|
20 |
-
end_idx = connection[1]
|
21 |
-
ax.plot([landmarks[start_idx, 0], landmarks[end_idx, 0]],
|
22 |
-
[landmarks[start_idx, 1], landmarks[end_idx, 1]], 'r-', linewidth=1)
|
23 |
-
ax.invert_yaxis()
|
24 |
-
ax.set_title(title, fontsize=12)
|
25 |
-
ax.axis('off')
|
26 |
-
return fig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|