Spaces:
Sleeping
Sleeping
color skeleton hands
Browse files
pipelines/text_to_sign/renderer.py
CHANGED
|
@@ -7,11 +7,18 @@ from .config import WIDTH, HEIGHT, FPS, POSE_CONNECTIONS
|
|
| 7 |
# =========================
|
| 8 |
WHITE = (255, 255, 255)
|
| 9 |
|
| 10 |
-
# #190124 in HEX
|
| 11 |
-
# RGB = (25, 1, 36)
|
| 12 |
-
# OpenCV uses BGR
|
| 13 |
BACKGROUND = (36, 1, 25)
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
# =========================
|
| 16 |
# HAND
|
| 17 |
# =========================
|
|
@@ -21,14 +28,16 @@ def draw_hand_stylish(img, hand_points, thickness=5):
|
|
| 21 |
pts = [(int(x * w), int(y * h)) for x, y, _ in hand_points]
|
| 22 |
|
| 23 |
fingers = {
|
| 24 |
-
"thumb":
|
| 25 |
-
"index":
|
| 26 |
"middle": [0, 9, 10, 11, 12],
|
| 27 |
-
"ring":
|
| 28 |
-
"pinky":
|
| 29 |
}
|
| 30 |
|
| 31 |
-
for idxs in fingers.
|
|
|
|
|
|
|
| 32 |
for i in range(len(idxs) - 1):
|
| 33 |
x1, y1 = pts[idxs[i]]
|
| 34 |
x2, y2 = pts[idxs[i + 1]]
|
|
@@ -37,7 +46,7 @@ def draw_hand_stylish(img, hand_points, thickness=5):
|
|
| 37 |
img,
|
| 38 |
(x1, y1),
|
| 39 |
(x2, y2),
|
| 40 |
-
|
| 41 |
thickness,
|
| 42 |
cv2.LINE_AA
|
| 43 |
)
|
|
@@ -123,7 +132,6 @@ def render(frames, output="output.mp4"):
|
|
| 123 |
)
|
| 124 |
|
| 125 |
for frame in frames:
|
| 126 |
-
# Create background using #190124
|
| 127 |
img = np.zeros((HEIGHT, WIDTH, 3), dtype=np.uint8)
|
| 128 |
img[:] = BACKGROUND
|
| 129 |
|
|
|
|
| 7 |
# =========================
|
| 8 |
WHITE = (255, 255, 255)
|
| 9 |
|
| 10 |
+
# Background (#190124 in HEX)
|
|
|
|
|
|
|
| 11 |
BACKGROUND = (36, 1, 25)
|
| 12 |
|
| 13 |
+
# Finger colors (BGR)
|
| 14 |
+
FINGER_COLORS = {
|
| 15 |
+
"thumb": (0, 0, 255), # Red
|
| 16 |
+
"index": (0, 255, 0), # Green
|
| 17 |
+
"middle": (255, 0, 0), # Blue
|
| 18 |
+
"ring": (0, 255, 255), # Yellow
|
| 19 |
+
"pinky": (255, 0, 255) # Magenta
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
# =========================
|
| 23 |
# HAND
|
| 24 |
# =========================
|
|
|
|
| 28 |
pts = [(int(x * w), int(y * h)) for x, y, _ in hand_points]
|
| 29 |
|
| 30 |
fingers = {
|
| 31 |
+
"thumb": [0, 1, 2, 3, 4],
|
| 32 |
+
"index": [0, 5, 6, 7, 8],
|
| 33 |
"middle": [0, 9, 10, 11, 12],
|
| 34 |
+
"ring": [0, 13, 14, 15, 16],
|
| 35 |
+
"pinky": [0, 17, 18, 19, 20]
|
| 36 |
}
|
| 37 |
|
| 38 |
+
for finger_name, idxs in fingers.items():
|
| 39 |
+
color = FINGER_COLORS[finger_name]
|
| 40 |
+
|
| 41 |
for i in range(len(idxs) - 1):
|
| 42 |
x1, y1 = pts[idxs[i]]
|
| 43 |
x2, y2 = pts[idxs[i + 1]]
|
|
|
|
| 46 |
img,
|
| 47 |
(x1, y1),
|
| 48 |
(x2, y2),
|
| 49 |
+
color,
|
| 50 |
thickness,
|
| 51 |
cv2.LINE_AA
|
| 52 |
)
|
|
|
|
| 132 |
)
|
| 133 |
|
| 134 |
for frame in frames:
|
|
|
|
| 135 |
img = np.zeros((HEIGHT, WIDTH, 3), dtype=np.uint8)
|
| 136 |
img[:] = BACKGROUND
|
| 137 |
|