lbw_review_system_V2 / live_review.py
dschandra's picture
Update live_review.py
3fef977 verified
# live_review.py
import cv2
import numpy as np
import tempfile
from utils import analyze_frame_sequence, overlay_annotations_dynamic, make_decision, render_annotated_clip
def analyze_live_video(video):
cap = cv2.VideoCapture(video)
frames = []
while True:
ret, frame = cap.read()
if not ret:
break
frames.append(frame)
cap.release()
recent_frames = frames[-30:] if len(frames) > 30 else frames
analysis = analyze_frame_sequence(recent_frames)
decision, reason = make_decision(analysis)
output_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
render_annotated_clip(recent_frames, analysis, decision, reason, output_path)
return decision, reason, output_path