reab5555 commited on
Commit
f8f9773
·
verified ·
1 Parent(s): fb1fff2

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +5 -4
visualization.py CHANGED
@@ -227,13 +227,17 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
227
  frame_count = 0
228
  total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
229
 
 
 
230
  while True:
231
  ret, frame = cap.read()
232
  if not ret:
233
  break
234
 
235
  # Update the heatmap with the current frame position
236
- ax.axvline(x=frame_count, color='r', linewidth=2)
 
 
237
 
238
  # Convert the matplotlib figure to an image
239
  canvas = FigureCanvasAgg(fig)
@@ -251,9 +255,6 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
251
 
252
  out.write(combined_frame)
253
  frame_count += 1
254
-
255
- # Remove the vertical line for the next iteration
256
- ax.lines.pop()
257
 
258
  cap.release()
259
  out.release()
 
227
  frame_count = 0
228
  total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
229
 
230
+ line = None # Initialize line object
231
+
232
  while True:
233
  ret, frame = cap.read()
234
  if not ret:
235
  break
236
 
237
  # Update the heatmap with the current frame position
238
+ if line:
239
+ line.remove() # Remove the previous line
240
+ line = ax.axvline(x=frame_count, color='r', linewidth=2)
241
 
242
  # Convert the matplotlib figure to an image
243
  canvas = FigureCanvasAgg(fig)
 
255
 
256
  out.write(combined_frame)
257
  frame_count += 1
 
 
 
258
 
259
  cap.release()
260
  out.release()