Update colab.py
Browse files
colab.py
CHANGED
@@ -194,62 +194,95 @@ class DanceGenerator:
|
|
194 |
def _create_enhanced_dance_frame(self, pose_array, frame_size, add_effects=True):
|
195 |
"""Create enhanced visualization frame with effects"""
|
196 |
height, width = frame_size
|
197 |
-
#
|
198 |
-
frame = np.
|
199 |
|
200 |
# Convert coordinates
|
201 |
points = (pose_array[:, :2] * [width, height]).astype(int)
|
202 |
|
203 |
-
# Draw enhanced skeleton with
|
204 |
connections = self._get_pose_connections()
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
if add_effects:
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
else:
|
227 |
-
cv2.circle(frame, tuple(point),
|
228 |
|
229 |
return frame
|
230 |
|
231 |
-
def _draw_glowing_line(self, frame, start, end, color, thickness=
|
232 |
-
"""Draw a line with enhanced glow effect"""
|
233 |
# Draw outer glow
|
234 |
for i in range(3):
|
235 |
-
alpha = 0.
|
236 |
-
thick = thickness + (i *
|
|
|
237 |
cv2.line(frame, tuple(start), tuple(end),
|
238 |
-
|
239 |
-
thick)
|
240 |
|
241 |
# Draw main line
|
242 |
cv2.line(frame, tuple(start), tuple(end), color, thickness)
|
243 |
|
244 |
-
def _draw_glowing_point(self, frame, point, color, radius=
|
245 |
-
"""Draw a point with enhanced glow effect"""
|
246 |
# Draw outer glow
|
247 |
for i in range(3):
|
248 |
-
alpha = 0.
|
249 |
-
r = radius + (i *
|
|
|
250 |
cv2.circle(frame, tuple(point), r,
|
251 |
-
|
252 |
-
-1)
|
253 |
|
254 |
# Draw main point
|
255 |
cv2.circle(frame, tuple(point), radius, color, -1)
|
|
|
194 |
def _create_enhanced_dance_frame(self, pose_array, frame_size, add_effects=True):
|
195 |
"""Create enhanced visualization frame with effects"""
|
196 |
height, width = frame_size
|
197 |
+
# Create transparent background
|
198 |
+
frame = np.zeros((height, width, 3), dtype=np.uint8) # Black background
|
199 |
|
200 |
# Convert coordinates
|
201 |
points = (pose_array[:, :2] * [width, height]).astype(int)
|
202 |
|
203 |
+
# Draw enhanced skeleton with neon effects
|
204 |
connections = self._get_pose_connections()
|
205 |
+
|
206 |
+
# Define body parts and their colors
|
207 |
+
body_parts = {
|
208 |
+
'spine': [(11, 23), (23, 24), (11, 12)], # Torso
|
209 |
+
'right_arm': [(11, 13), (13, 15)], # Right arm
|
210 |
+
'left_arm': [(12, 14), (14, 16)], # Left arm
|
211 |
+
'right_leg': [(23, 25), (25, 27), (27, 29), (29, 31)], # Right leg
|
212 |
+
'left_leg': [(24, 26), (26, 28), (28, 30), (30, 32)], # Left leg
|
213 |
+
'face': [(0, 1), (1, 2), (2, 3), (3, 7), (0, 4), (4, 5), (5, 6), (6, 8)] # Face
|
214 |
+
}
|
215 |
+
|
216 |
+
colors = {
|
217 |
+
'spine': (0, 255, 255), # Cyan
|
218 |
+
'right_arm': (0, 255, 0), # Green
|
219 |
+
'left_arm': (0, 255, 0), # Green
|
220 |
+
'right_leg': (255, 0, 255), # Magenta
|
221 |
+
'left_leg': (255, 0, 255), # Magenta
|
222 |
+
'face': (255, 255, 0) # Yellow
|
223 |
+
}
|
224 |
+
|
225 |
+
# Draw body parts with glow effects
|
226 |
+
for part, connections_list in body_parts.items():
|
227 |
+
color = colors[part]
|
228 |
+
for connection in connections_list:
|
229 |
+
start_idx, end_idx = connection
|
230 |
+
if start_idx < len(points) and end_idx < len(points):
|
231 |
+
if add_effects:
|
232 |
+
self._draw_glowing_line(
|
233 |
+
frame,
|
234 |
+
points[start_idx],
|
235 |
+
points[end_idx],
|
236 |
+
color,
|
237 |
+
thickness=3
|
238 |
+
)
|
239 |
+
else:
|
240 |
+
cv2.line(frame,
|
241 |
+
tuple(points[start_idx]),
|
242 |
+
tuple(points[end_idx]),
|
243 |
+
color, 3)
|
244 |
+
|
245 |
+
# Draw enhanced joints with glow
|
246 |
+
for i, point in enumerate(points):
|
247 |
if add_effects:
|
248 |
+
# Different colors for different body parts
|
249 |
+
if i in [0,1,2,3,4,5,6,7,8]: # Face points
|
250 |
+
color = (255, 255, 0) # Yellow
|
251 |
+
elif i in [11,12,23,24]: # Torso points
|
252 |
+
color = (0, 255, 255) # Cyan
|
253 |
+
elif i in [13,14,15,16]: # Arms points
|
254 |
+
color = (0, 255, 0) # Green
|
255 |
+
else: # Legs points
|
256 |
+
color = (255, 0, 255) # Magenta
|
257 |
+
|
258 |
+
self._draw_glowing_point(frame, point, color, radius=4)
|
259 |
else:
|
260 |
+
cv2.circle(frame, tuple(point), 4, (255, 255, 255), -1)
|
261 |
|
262 |
return frame
|
263 |
|
264 |
+
def _draw_glowing_line(self, frame, start, end, color, thickness=3):
|
265 |
+
"""Draw a line with enhanced neon glow effect"""
|
266 |
# Draw outer glow
|
267 |
for i in range(3):
|
268 |
+
alpha = 0.3 - i * 0.1
|
269 |
+
thick = thickness + (i * 2)
|
270 |
+
blur_color = tuple([int(c * alpha) for c in color])
|
271 |
cv2.line(frame, tuple(start), tuple(end),
|
272 |
+
blur_color, thick)
|
|
|
273 |
|
274 |
# Draw main line
|
275 |
cv2.line(frame, tuple(start), tuple(end), color, thickness)
|
276 |
|
277 |
+
def _draw_glowing_point(self, frame, point, color, radius=4):
|
278 |
+
"""Draw a point with enhanced neon glow effect"""
|
279 |
# Draw outer glow
|
280 |
for i in range(3):
|
281 |
+
alpha = 0.3 - i * 0.1
|
282 |
+
r = radius + (i * 2)
|
283 |
+
blur_color = tuple([int(c * alpha) for c in color])
|
284 |
cv2.circle(frame, tuple(point), r,
|
285 |
+
blur_color, -1)
|
|
|
286 |
|
287 |
# Draw main point
|
288 |
cv2.circle(frame, tuple(point), radius, color, -1)
|