Spaces:
Runtime error
Runtime error
File size: 559 Bytes
7ce6353 bd32e54 67831c3 7ce6353 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import cv2
import numpy as np
def extract_frames(video_path):
"""Extract frames from a video."""
cap = cv2.VideoCapture(video_path)
frames = []
while cap.isOpened():
ret, frame = cap.read()
if not ret:
break
frames.append(frame)
cap.release()
return frames
def preprocess_image(image):
"""Preprocess image for model input."""
if image is None:
raise ValueError("Input image is None.")
image = cv2.resize(image, (320, 320)) # Reduced size for faster processing
return image |