plantation_project / preprocess.py
lokesh341's picture
Update preprocess.py
f74c498 verified
raw
history blame contribute delete
559 Bytes
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