Update video_processing.py
Browse files- video_processing.py +11 -3
video_processing.py
CHANGED
@@ -10,7 +10,7 @@ from face_analysis import get_face_embedding, cluster_faces, organize_faces_by_p
|
|
10 |
from pose_analysis import pose, calculate_posture_score, draw_pose_landmarks
|
11 |
from voice_analysis import get_speaker_embeddings, align_voice_embeddings, extract_audio_from_video, diarize_speakers
|
12 |
from anomaly_detection import anomaly_detection
|
13 |
-
from visualization import plot_mse, plot_mse_histogram, plot_mse_heatmap, create_video_with_heatmap
|
14 |
from utils import frame_to_timecode
|
15 |
import pandas as pd
|
16 |
from facenet_pytorch import MTCNN
|
@@ -209,6 +209,12 @@ def process_video(video_path, anomaly_threshold, desired_fps, progress=None):
|
|
209 |
mse_heatmap_embeddings = plot_mse_heatmap(mse_embeddings, "Facial Features MSE Heatmap", df)
|
210 |
mse_heatmap_posture = plot_mse_heatmap(mse_posture, "Body Posture MSE Heatmap", df)
|
211 |
mse_heatmap_voice = plot_mse_heatmap(mse_voice, "Voice MSE Heatmap", df)
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
try:
|
214 |
if progress is not None:
|
@@ -238,7 +244,7 @@ def process_video(video_path, anomaly_threshold, desired_fps, progress=None):
|
|
238 |
print(f"Error details: {str(e)}")
|
239 |
import traceback
|
240 |
traceback.print_exc()
|
241 |
-
return (f"Error in video processing: {str(e)}",) + (None,) *
|
242 |
|
243 |
progress(1.0, "Preparing results")
|
244 |
results = f"Number of persons detected: {num_clusters}\n\n"
|
@@ -305,7 +311,9 @@ def process_video(video_path, anomaly_threshold, desired_fps, progress=None):
|
|
305 |
anomaly_frames_posture_images,
|
306 |
aligned_faces_folder,
|
307 |
frames_folder,
|
308 |
-
heatmap_video_path
|
|
|
|
|
309 |
)
|
310 |
|
311 |
def is_frontal_face(landmarks, threshold=60):
|
|
|
10 |
from pose_analysis import pose, calculate_posture_score, draw_pose_landmarks
|
11 |
from voice_analysis import get_speaker_embeddings, align_voice_embeddings, extract_audio_from_video, diarize_speakers
|
12 |
from anomaly_detection import anomaly_detection
|
13 |
+
from visualization import plot_mse, plot_mse_histogram, plot_mse_heatmap, create_video_with_heatmap, plot_correlation_heatmap, plot_3d_scatter
|
14 |
from utils import frame_to_timecode
|
15 |
import pandas as pd
|
16 |
from facenet_pytorch import MTCNN
|
|
|
209 |
mse_heatmap_embeddings = plot_mse_heatmap(mse_embeddings, "Facial Features MSE Heatmap", df)
|
210 |
mse_heatmap_posture = plot_mse_heatmap(mse_posture, "Body Posture MSE Heatmap", df)
|
211 |
mse_heatmap_voice = plot_mse_heatmap(mse_voice, "Voice MSE Heatmap", df)
|
212 |
+
|
213 |
+
# Generate the correlation heatmap
|
214 |
+
correlation_heatmap = plot_correlation_heatmap(mse_embeddings, mse_posture, mse_voice)
|
215 |
+
|
216 |
+
# Generate the 3D scatter plot
|
217 |
+
scatter_plot_3d = plot_3d_scatter(mse_embeddings, mse_posture, mse_voice)
|
218 |
|
219 |
try:
|
220 |
if progress is not None:
|
|
|
244 |
print(f"Error details: {str(e)}")
|
245 |
import traceback
|
246 |
traceback.print_exc()
|
247 |
+
return (f"Error in video processing: {str(e)}",) + (None,) * 23
|
248 |
|
249 |
progress(1.0, "Preparing results")
|
250 |
results = f"Number of persons detected: {num_clusters}\n\n"
|
|
|
311 |
anomaly_frames_posture_images,
|
312 |
aligned_faces_folder,
|
313 |
frames_folder,
|
314 |
+
heatmap_video_path,
|
315 |
+
correlation_heatmap,
|
316 |
+
scatter_plot_3d
|
317 |
)
|
318 |
|
319 |
def is_frontal_face(landmarks, threshold=60):
|