app.py
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 32 33 34 |
import cv2 import os cam = cv2.VideoCapture("files/1.mkv") try: if not os.path.exists('data'): os.makedirs('data') except OSError: print ('Error: Creating directory of data') # frame currentframe = 0 while(True): # reading from frame ret,frame = cam.read() if ret: name = './data/frame' + str(currentframe) + '.jpg' print ('Creating...' + name) cv2.imwrite(name, frame) currentframe += 1 else: break cam.release() cv2.destroyAllWindows() |