Spaces:
Sleeping
Sleeping
Update upload_review.py
Browse files- upload_review.py +6 -9
upload_review.py
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
| 5 |
import tempfile
|
| 6 |
-
from utils import analyze_frame_sequence,
|
| 7 |
|
| 8 |
def analyze_uploaded_video(video):
|
| 9 |
cap = cv2.VideoCapture(video)
|
|
@@ -15,16 +15,13 @@ def analyze_uploaded_video(video):
|
|
| 15 |
frames.append(frame)
|
| 16 |
cap.release()
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
analysis = analyze_frame_sequence(frames)
|
| 19 |
decision, reason = make_decision(analysis)
|
| 20 |
|
| 21 |
-
annotated_frames = overlay_annotations(frames, analysis)
|
| 22 |
-
|
| 23 |
output_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
| 24 |
-
|
| 25 |
-
out = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'mp4v'), 20.0, (w, h))
|
| 26 |
-
for f in annotated_frames:
|
| 27 |
-
out.write(f)
|
| 28 |
-
out.release()
|
| 29 |
|
| 30 |
-
return decision, reason, output_path
|
|
|
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
| 5 |
import tempfile
|
| 6 |
+
from utils import analyze_frame_sequence, make_decision, render_annotated_clip
|
| 7 |
|
| 8 |
def analyze_uploaded_video(video):
|
| 9 |
cap = cv2.VideoCapture(video)
|
|
|
|
| 15 |
frames.append(frame)
|
| 16 |
cap.release()
|
| 17 |
|
| 18 |
+
if len(frames) == 0:
|
| 19 |
+
return "Decision pending – insufficient data", "No frames found.", None
|
| 20 |
+
|
| 21 |
analysis = analyze_frame_sequence(frames)
|
| 22 |
decision, reason = make_decision(analysis)
|
| 23 |
|
|
|
|
|
|
|
| 24 |
output_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
| 25 |
+
render_annotated_clip(frames, analysis, decision, reason, output_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
return f"FINAL DECISION: {decision}", reason, output_path
|