Spaces:
Sleeping
Sleeping
File size: 766 Bytes
e826484 | 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 29 30 | # utils/__init__.py
# ํจํค์ง ์ด๊ธฐํ ํ์ผ
def extract_frames(video_path, max_frames=10, skip=10):
"""
๋์์์์ ํ๋ ์ ์ถ์ถ
Args:
video_path: ๋์์ ํ์ผ ๊ฒฝ๋ก
max_frames: ์ถ์ถํ ์ต๋ ํ๋ ์ ์
skip: ๊ฑด๋๋ธ ํ๋ ์ ์
Returns:
์ถ์ถ๋ ํ๋ ์ ๋ฆฌ์คํธ
"""
import cv2
cap = cv2.VideoCapture(video_path)
frames = []
count = 0
while cap.isOpened() and len(frames) < max_frames:
ret, frame = cap.read()
if not ret:
break
if count % skip == 0:
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frames.append(frame_rgb)
count += 1
cap.release()
return frames |