Spaces:
Sleeping
Sleeping
File size: 721 Bytes
770130f |
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 |
import cv2
import os
import tempfile
from detector import LBWDetector
from utils import draw_boxes
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)
out.write(frame)
cap.release()
out.release()
return output_path
|