python实现视频读取和转化图片

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python实现视频读取和转化图片

  2021-04-02 我要评论

1)视频读取

import cv2

cap = cv2.VideoCapture('E:\\Video\\20000105_224116.dav') #地址

while(True):

  ret,frame = cap.read()

  if(ret):

    # gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)

    cv2.imshow('input',frame)

  else:

    break

  if cv2.waitKey(1)==27:

    break

cap.release()

cv2.destroyAllWindows()

2)转化图片

# -*- coding: utf-8 -*-
"""
Created on Mon Nov 5 15:21:15 2018

@author: chenjin10
"""

import cv2
vc = cv2.VideoCapture('E:\\Video\\binggan.dav')
c=0
rval=vc.isOpened()

while rval:
  c = c + 1
  rval, frame = vc.read()
  if rval:
    cv2.imwrite('E:\\Video\\binggan\\'+'camera1_binggan'+str(c) + '.jpg', frame) #命名方式
    print(c)
  else:
    break
vc.release()

以上这篇python实现视频读取和转化图片就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们