File size: 925 Bytes
770130f
d733ee8
 
770130f
c03a5f7
770130f
 
 
 
 
c03a5f7
770130f
 
 
 
 
 
 
 
 
 
 
d733ee8
 
 
770130f
 
 
 
d733ee8
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
29
30
import cv2
import os
import tempfile
from detector import LBWDetector
from utils import draw_boxes, overlay_decision_text

def process_video(video_path, output_path="output.mp4"):
    detector = LBWDetector()
    cap = cv2.VideoCapture(video_path)

    width = int(cap.get(3))
    height = int(cap.get(4))
    fps = cap.get(cv2.CAP_PROP_FPS)

    out = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'mp4v'), fps, (width, height))

    while cap.isOpened():
        ret, frame = cap.read()
        if not ret:
            break
        detections, class_names = detector.detect_objects(frame)
        frame = draw_boxes(frame, detections, class_names)
        # Placeholder decision; replace with actual LBW logic later
        decision = "Pending"  # Example: "Out" or "Not Out"
        frame = overlay_decision_text(frame, decision)
        out.write(frame)

    cap.release()
    out.release()
    return output_path