Spaces:
Sleeping
Sleeping
File size: 758 Bytes
337c929 3fef977 337c929 3fef977 337c929 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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
|