일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- pyTorch
- face_recognition
- colab
- TensorFlow
- install
- raspberry pi
- ubuntu
- error
- download
- CUDA
- dataset
- python
- Anaconda
- windows
- Deep Learning
- urllib
- Windows 10
- linux
- YouTube 8M
- Jupyter notebook
- colaboratory
- shakeratos
- gpu memory
- FIle
- dlib
- python3
- ppc64le
- 딥러닝
- object detection
- keras
- Today
- Total
Shakerato
video frame image extraction (video to frame images) (python) 본문
import cv2 import os
input_vid_name = 'input.mp4' output_frame_folder = 'output'
cap = cv2.VideoCapture(input_vid_name) vid_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) vid_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) vid_length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
if not os.path.exists(output_frame_folder): os.makedirs(output_frame_folder)
for framenum in range(0, vid_length): print(framenum) cap.set(cv2.CAP_PROP_FRAME_COUNT, framenum) ret,frame = cap.read() if ret is False: break
# Image Processing cv2.imwrite(output_frame_folder + '/' + str(framenum).zfill(5) + '.png', frame) cv2.imshow('frame', frame) k = cv2.waitKey(1) & 0xff if k == 27: # Escape (ESC) break
cap.release() cv2.destroyAllWindows() |