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