Last active
December 30, 2018 20:17
-
-
Save alpercalisir/260898bbbd6592283ed82c183f54ef93 to your computer and use it in GitHub Desktop.
Split video by frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import os | |
cap = cv2.VideoCapture('IMG_4230.MOV') | |
if not os.path.exists('training_images'): | |
os.makedirs('training_images') | |
userid = 'x' | |
if not os.path.exists('training_images/'+userid): | |
os.makedirs('training_images/'+userid) | |
count=0 | |
name_counter = 0 | |
success=True | |
while count<1800: | |
ret, frame = cap.read() | |
name = './training_images/'+userid+ '/frame' + str(name_counter) +'_'+userid+ '.jpg' | |
print ('Creating...' + name) | |
if count%30==0: | |
name_counter += 1 | |
cv2.imwrite(name, frame) | |
count += 1 | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment