Spaces:
Sleeping
Sleeping
Download utils/__init__.py from shin0624/Factory_Layout_Simulator: direct link, hf CLI and curl.
- Browser
- Download file 766 Bytes
-
https://huggingface.co/spaces/shin0624/Factory_Layout_Simulator/resolve/main/utils/__init__.py
- Command line
-
hf download hf://spaces/shin0624/Factory_Layout_Simulator/utils/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/shin0624/Factory_Layout_Simulator/resolve/main/utils/__init__.py
766 Bytes
| # 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 |