Update visualization.py
Browse files- visualization.py +5 -4
visualization.py
CHANGED
@@ -217,7 +217,7 @@ def plot_posture(df, posture_scores, color='blue', anomaly_threshold=3):
|
|
217 |
return fig
|
218 |
|
219 |
|
220 |
-
def create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video_fps, total_frames):
|
221 |
frame_count = int(t * video_fps)
|
222 |
|
223 |
# Normalize MSE values
|
@@ -230,7 +230,7 @@ def create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video_fps, total_f
|
|
230 |
combined_mse[1] = mse_posture_norm
|
231 |
combined_mse[2] = mse_voice_norm
|
232 |
|
233 |
-
fig, ax = plt.subplots(figsize=(
|
234 |
ax.imshow(combined_mse, aspect='auto', cmap='coolwarm', vmin=0, vmax=1, extent=[0, total_frames, 0, 3])
|
235 |
ax.set_yticks([0.5, 1.5, 2.5])
|
236 |
ax.set_yticklabels(['Face', 'Posture', 'Voice'])
|
@@ -272,8 +272,9 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
|
|
272 |
|
273 |
def combine_video_and_heatmap(t):
|
274 |
video_frame = video.get_frame(t)
|
275 |
-
heatmap_frame = create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video.fps, total_frames)
|
276 |
-
|
|
|
277 |
return combined_frame
|
278 |
|
279 |
final_clip = VideoClip(combine_video_and_heatmap, duration=video.duration)
|
|
|
217 |
return fig
|
218 |
|
219 |
|
220 |
+
def create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video_fps, total_frames, video_width):
|
221 |
frame_count = int(t * video_fps)
|
222 |
|
223 |
# Normalize MSE values
|
|
|
230 |
combined_mse[1] = mse_posture_norm
|
231 |
combined_mse[2] = mse_voice_norm
|
232 |
|
233 |
+
fig, ax = plt.subplots(figsize=(video_width / 100, 2))
|
234 |
ax.imshow(combined_mse, aspect='auto', cmap='coolwarm', vmin=0, vmax=1, extent=[0, total_frames, 0, 3])
|
235 |
ax.set_yticks([0.5, 1.5, 2.5])
|
236 |
ax.set_yticklabels(['Face', 'Posture', 'Voice'])
|
|
|
272 |
|
273 |
def combine_video_and_heatmap(t):
|
274 |
video_frame = video.get_frame(t)
|
275 |
+
heatmap_frame = create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video.fps, total_frames, width)
|
276 |
+
heatmap_frame_resized = cv2.resize(heatmap_frame, (width, heatmap_frame.shape[0]))
|
277 |
+
combined_frame = np.vstack((video_frame, heatmap_frame_resized))
|
278 |
return combined_frame
|
279 |
|
280 |
final_clip = VideoClip(combine_video_and_heatmap, duration=video.duration)
|