Search
📄

1) Video to Img

Environment Setup

•
anaconda
•
windows10

Split the Video to Image frame using openCV

Install OpenCV

!pip install opencv-python
Python
복사

Split Video to Image frame

import cv2 import os input_vid_name = 'data/IMG_9998.mp4' output_frame_folder = 'frame' cap = cv2.VideoCapture(input_vid_name) frame_num = 0 if not os.path.exists(output_frame_folder): os.makedirs(output_frame_folder) while (True): ret, frame = cap.read() if ret is False: break print(frame_num) cap.set(cv2.CAP_PROP_FRAME_COUNT, frame_num) # Image Processing cv2.imwrite(output_frame_folder + '/' + str(frame_num).zfill(5) + '.jpg', frame) frame_num += 1 k = cv2.waitKey(1) & 0xff if k == 27: # Escape (ESC) break cap.release()
Python
복사

Result

Image