lbw_review_system_V2 / upload_review.py
dschandra's picture
Update upload_review.py
11491ba verified
# upload_review.py
import cv2
import numpy as np
import tempfile
from utils import analyze_frame_sequence, make_decision, render_annotated_clip
def analyze_uploaded_video(video):
cap = cv2.VideoCapture(video)
frames = []
while True:
ret, frame = cap.read()
if not ret:
break
frames.append(frame)
cap.release()
if len(frames) == 0:
return "Decision pending – insufficient data", "No frames found.", None
analysis = analyze_frame_sequence(frames)
decision, reason = make_decision(analysis)
output_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
render_annotated_clip(frames, analysis, decision, reason, output_path)
return f"FINAL DECISION: {decision}", reason, output_path