首页 > 编程语言 > 详细

python,opencv视频

时间:2019-02-12 13:02:36      阅读:172      评论:0      收藏:0      [点我收藏+]
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 29 09:58:37 2018

@author: LX
"""

import os
import cv2
videos_src_path = D:\\
videos_save_path = D:\\b

videos = os.listdir(videos_src_path)
videos = filter(lambda x: x.endswith(mp4), videos)

for each_video in videos:
    print (each_video)

    # get the name of each video, and make the directory to save frames
    each_video_name, _ = each_video.split(.)
    os.mkdir(videos_save_path + / + each_video_name)               

    each_video_save_full_path = os.path.join(videos_save_path, each_video_name) + \‘

    # get the full path of each video, which will open the video tp extract frames
    each_video_full_path = os.path.join(videos_src_path, each_video)

    cap  = cv2.VideoCapture(each_video_full_path)
    frame_count = 1
    success = True
    while(success):
        success, frame = cap.read()
        print (Read a new frame: , success)

        params = []
        params.append(cv.CV_IMWRITE_PXM_BINARY)
        params.append(1)
        cv2.imwrite(each_video_save_full_path + each_video_name + "_%d.ppm" % frame_count, frame, params)

        frame_count = frame_count + 1

cap.release()

 

python,opencv视频

原文:https://www.cnblogs.com/lely/p/10364402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!