reab5555 commited on
Commit
edbec6e
·
verified ·
1 Parent(s): 14f522f

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +5 -3
visualization.py CHANGED
@@ -215,7 +215,7 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
215
  out = cv2.VideoWriter(output_path, fourcc, desired_fps, (width, height + 200))
216
 
217
  # Create custom colormap
218
- colors = ['navy', 'blue', 'white', 'purple', 'magenta']
219
  n_bins = 100
220
  cmap = mcolors.LinearSegmentedColormap.from_list('custom', colors, N=n_bins)
221
 
@@ -226,7 +226,7 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
226
  mse_embeddings_norm = (mse_embeddings - np.nanmin(mse_embeddings)) / (np.nanmax(mse_embeddings) - np.nanmin(mse_embeddings))
227
  mse_posture_norm = (mse_posture - np.nanmin(mse_posture)) / (np.nanmax(mse_posture) - np.nanmin(mse_posture))
228
 
229
- # Combine MSEs: negative for facial features, positive for body posture
230
  combined_mse = mse_posture_norm - mse_embeddings_norm
231
 
232
  fig, ax = plt.subplots(figsize=(width/100, 2))
@@ -259,7 +259,9 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
259
 
260
  combined_frame = np.vstack((frame, heatmap_img))
261
 
262
- timecode = df['Timecode'][frame_count] if frame_count < len(df) else "End"
 
 
263
  cv2.putText(combined_frame, f"Time: {timecode}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
264
 
265
  out.write(combined_frame)
 
215
  out = cv2.VideoWriter(output_path, fourcc, desired_fps, (width, height + 200))
216
 
217
  # Create custom colormap
218
+ colors = ['navy', 'white', 'purple'] # Changed order: blue for facial, purple for posture
219
  n_bins = 100
220
  cmap = mcolors.LinearSegmentedColormap.from_list('custom', colors, N=n_bins)
221
 
 
226
  mse_embeddings_norm = (mse_embeddings - np.nanmin(mse_embeddings)) / (np.nanmax(mse_embeddings) - np.nanmin(mse_embeddings))
227
  mse_posture_norm = (mse_posture - np.nanmin(mse_posture)) / (np.nanmax(mse_posture) - np.nanmin(mse_posture))
228
 
229
+ # Combine MSEs: negative for facial features (blue), positive for body posture (purple)
230
  combined_mse = mse_posture_norm - mse_embeddings_norm
231
 
232
  fig, ax = plt.subplots(figsize=(width/100, 2))
 
259
 
260
  combined_frame = np.vstack((frame, heatmap_img))
261
 
262
+ # Use frame_count to get timecode, not df index
263
+ seconds = frame_count / original_fps
264
+ timecode = f"{int(seconds//3600):02d}:{int((seconds%3600)//60):02d}:{int(seconds%60):02d}"
265
  cv2.putText(combined_frame, f"Time: {timecode}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
266
 
267
  out.write(combined_frame)