ombhojane commited on
Commit
b446ed6
·
verified ·
1 Parent(s): 03327e0

Upload dance_generator.py

Browse files
Files changed (1) hide show
  1. dance_generator.py +32 -1
dance_generator.py CHANGED
@@ -249,4 +249,35 @@ class DanceGenerator:
249
  (23, 24), (23, 25), (24, 26), # Legs
250
  (25, 27), (26, 28), (27, 29), (28, 30),
251
  (29, 31), (30, 32)
252
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  (23, 24), (23, 25), (24, 26), # Legs
250
  (25, 27), (26, 28), (27, 29), (28, 30),
251
  (29, 31), (30, 32)
252
+ ]
253
+
254
+ def _smooth_transition(self, prev_pose, current_pose, smoothing_factor=0.3):
255
+ """Create smooth transition between poses"""
256
+ if prev_pose is None or current_pose is None:
257
+ return current_pose
258
+
259
+ # Interpolate between previous and current pose
260
+ smoothed_pose = (1 - smoothing_factor) * prev_pose + smoothing_factor * current_pose
261
+
262
+ # Ensure the smoothed pose maintains proper proportions
263
+ # Normalize joint positions relative to hip center
264
+ hip_center_idx = 23 # Index for hip center landmark
265
+
266
+ prev_hip = prev_pose[hip_center_idx]
267
+ current_hip = current_pose[hip_center_idx]
268
+ smoothed_hip = smoothed_pose[hip_center_idx]
269
+
270
+ # Adjust positions relative to hip center
271
+ for i in range(len(smoothed_pose)):
272
+ if i != hip_center_idx:
273
+ # Calculate relative positions
274
+ prev_relative = prev_pose[i] - prev_hip
275
+ current_relative = current_pose[i] - current_hip
276
+
277
+ # Interpolate relative positions
278
+ smoothed_relative = (1 - smoothing_factor) * prev_relative + smoothing_factor * current_relative
279
+
280
+ # Update smoothed pose
281
+ smoothed_pose[i] = smoothed_hip + smoothed_relative
282
+
283
+ return smoothed_pose