Update colab.py
Browse files
colab.py
CHANGED
@@ -191,64 +191,65 @@ class DanceGenerator:
|
|
191 |
def _create_enhanced_dance_frame(self, pose_array, frame_size, add_effects=True):
|
192 |
"""Create enhanced visualization frame with effects"""
|
193 |
height, width = frame_size
|
194 |
-
|
195 |
-
|
|
|
196 |
# Convert coordinates
|
197 |
points = (pose_array[:, :2] * [width, height]).astype(int)
|
198 |
-
|
199 |
-
# Draw enhanced skeleton
|
200 |
connections = self._get_pose_connections()
|
201 |
for connection in connections:
|
202 |
start_idx, end_idx = connection
|
203 |
if start_idx < len(points) and end_idx < len(points):
|
204 |
-
# Draw glowing lines
|
205 |
if add_effects:
|
206 |
self._draw_glowing_line(
|
207 |
frame,
|
208 |
points[start_idx],
|
209 |
points[end_idx],
|
210 |
-
(0, 255,
|
|
|
211 |
)
|
212 |
else:
|
213 |
cv2.line(frame,
|
214 |
tuple(points[start_idx]),
|
215 |
tuple(points[end_idx]),
|
216 |
-
(0,
|
217 |
|
218 |
-
# Draw enhanced joints
|
219 |
for point in points:
|
220 |
if add_effects:
|
221 |
-
self._draw_glowing_point(frame, point, (0, 0,
|
222 |
else:
|
223 |
-
cv2.circle(frame, tuple(point),
|
224 |
|
225 |
return frame
|
226 |
|
227 |
-
def _draw_glowing_line(self, frame, start, end, color, thickness=
|
228 |
-
"""Draw a line with glow effect"""
|
229 |
-
# Draw
|
230 |
-
cv2.line(frame, tuple(start), tuple(end), color, thickness)
|
231 |
-
|
232 |
-
# Draw glow
|
233 |
for i in range(3):
|
234 |
-
alpha = 0.
|
235 |
-
|
236 |
cv2.line(frame, tuple(start), tuple(end),
|
237 |
tuple([int(c * alpha) for c in color]),
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
# Draw main point
|
243 |
-
cv2.circle(frame, tuple(point), radius, color, -1)
|
244 |
|
245 |
-
|
|
|
|
|
246 |
for i in range(3):
|
247 |
-
alpha = 0.
|
248 |
-
r = radius + i *
|
249 |
cv2.circle(frame, tuple(point), r,
|
250 |
tuple([int(c * alpha) for c in color]),
|
251 |
-1)
|
|
|
|
|
|
|
252 |
|
253 |
def _landmarks_to_array(self, landmarks):
|
254 |
"""Convert MediaPipe landmarks to numpy array"""
|
|
|
191 |
def _create_enhanced_dance_frame(self, pose_array, frame_size, add_effects=True):
|
192 |
"""Create enhanced visualization frame with effects"""
|
193 |
height, width = frame_size
|
194 |
+
# Change background from black to light gray for better visibility
|
195 |
+
frame = np.ones((height, width, 3), dtype=np.uint8) * 240 # Light gray background
|
196 |
+
|
197 |
# Convert coordinates
|
198 |
points = (pose_array[:, :2] * [width, height]).astype(int)
|
199 |
+
|
200 |
+
# Draw enhanced skeleton with thicker lines and more visible colors
|
201 |
connections = self._get_pose_connections()
|
202 |
for connection in connections:
|
203 |
start_idx, end_idx = connection
|
204 |
if start_idx < len(points) and end_idx < len(points):
|
|
|
205 |
if add_effects:
|
206 |
self._draw_glowing_line(
|
207 |
frame,
|
208 |
points[start_idx],
|
209 |
points[end_idx],
|
210 |
+
(0, 100, 255), # Orange color for skeleton
|
211 |
+
thickness=4
|
212 |
)
|
213 |
else:
|
214 |
cv2.line(frame,
|
215 |
tuple(points[start_idx]),
|
216 |
tuple(points[end_idx]),
|
217 |
+
(0, 100, 255), 4)
|
218 |
|
219 |
+
# Draw enhanced joints with larger radius
|
220 |
for point in points:
|
221 |
if add_effects:
|
222 |
+
self._draw_glowing_point(frame, point, (255, 0, 0), radius=6) # Blue joints
|
223 |
else:
|
224 |
+
cv2.circle(frame, tuple(point), 6, (255, 0, 0), -1)
|
225 |
|
226 |
return frame
|
227 |
|
228 |
+
def _draw_glowing_line(self, frame, start, end, color, thickness=4):
|
229 |
+
"""Draw a line with enhanced glow effect"""
|
230 |
+
# Draw outer glow
|
|
|
|
|
|
|
231 |
for i in range(3):
|
232 |
+
alpha = 0.5 - i * 0.15
|
233 |
+
thick = thickness + (i * 4)
|
234 |
cv2.line(frame, tuple(start), tuple(end),
|
235 |
tuple([int(c * alpha) for c in color]),
|
236 |
+
thick)
|
237 |
+
|
238 |
+
# Draw main line
|
239 |
+
cv2.line(frame, tuple(start), tuple(end), color, thickness)
|
|
|
|
|
240 |
|
241 |
+
def _draw_glowing_point(self, frame, point, color, radius=6):
|
242 |
+
"""Draw a point with enhanced glow effect"""
|
243 |
+
# Draw outer glow
|
244 |
for i in range(3):
|
245 |
+
alpha = 0.5 - i * 0.15
|
246 |
+
r = radius + (i * 3)
|
247 |
cv2.circle(frame, tuple(point), r,
|
248 |
tuple([int(c * alpha) for c in color]),
|
249 |
-1)
|
250 |
+
|
251 |
+
# Draw main point
|
252 |
+
cv2.circle(frame, tuple(point), radius, color, -1)
|
253 |
|
254 |
def _landmarks_to_array(self, landmarks):
|
255 |
"""Convert MediaPipe landmarks to numpy array"""
|