File size: 785 Bytes
1031306
 
 
 
 
11491ba
1031306
 
 
 
 
 
 
 
 
 
 
11491ba
 
 
1031306
 
 
 
11491ba
1031306
11491ba
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
27
28
# 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