reab5555 commited on
Commit
4c42431
·
verified ·
1 Parent(s): 3d750e0

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +5 -7
visualization.py CHANGED
@@ -267,16 +267,14 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
267
  ax.set_xticks([])
268
  plt.tight_layout()
269
 
270
- def make_frame(t):
 
271
  frame_count = int(t * video.fps)
272
 
273
- # Get the frame from the original video
274
- frame = video.get_frame(t)
275
-
276
  # Update heatmap
277
  if hasattr(ax, 'line'):
278
- ax.line.remove()
279
- ax.line = ax.axvline(x=frame_count, color='r', linewidth=2)
280
 
281
  canvas = FigureCanvasAgg(fig)
282
  canvas.draw()
@@ -291,7 +289,7 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
291
  seconds = t
292
  timecode = f"{int(seconds//3600):02d}:{int((seconds%3600)//60):02d}:{int(seconds%60):02d}"
293
 
294
- pil_img = Image.fromarray(combined_frame)
295
  draw = ImageDraw.Draw(pil_img)
296
  font = ImageFont.load_default()
297
  draw.text((10, 30), f"Time: {timecode}", font=font, fill=(255, 255, 255))
 
267
  ax.set_xticks([])
268
  plt.tight_layout()
269
 
270
+ def make_frame(frame):
271
+ t = frame / video.fps if isinstance(frame, np.ndarray) else frame
272
  frame_count = int(t * video.fps)
273
 
 
 
 
274
  # Update heatmap
275
  if hasattr(ax, 'line'):
276
+ ax.lines.pop(0)
277
+ ax.axvline(x=frame_count, color='r', linewidth=2)
278
 
279
  canvas = FigureCanvasAgg(fig)
280
  canvas.draw()
 
289
  seconds = t
290
  timecode = f"{int(seconds//3600):02d}:{int((seconds%3600)//60):02d}:{int(seconds%60):02d}"
291
 
292
+ pil_img = Image.fromarray(combined_frame.astype('uint8'))
293
  draw = ImageDraw.Draw(pil_img)
294
  font = ImageFont.load_default()
295
  draw.text((10, 30), f"Time: {timecode}", font=font, fill=(255, 255, 255))