process_frames.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:commercials_project 作者: BryceLuna 项目源码 文件源码
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()
            cv2.imwrite(w_path,frame)
            count+=step_size
        vid.release()
    else:
        print 'unable to open file: {}'.format(file_str)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号