def get_frames(file_str):
'''
string => None
This function takes in the source of a video, samples from
the video and writes those samples to a folder
'''
vid = cv2.VideoCapture(file_str)
if vid.isOpened():
frame_count = int(vid.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
step_size = int(1/float(pct_frames))
for count in xrange(0,frame_count,step_size):
w_path = write_path(file_str,count)
vid.set(cv2.cv.CV_CAP_PROP_POS_FRAMES,count)
ret, frame = vid.read()
count+=step_size
return frame
vid.release()
else:
print 'unable to open file: {}'.format(file_str)
评论列表
文章目录