Spaces:
Runtime error
Runtime error
| 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 |