网络编程
位置:首页>> 网络编程>> Python编程>> python实现视频读取和转化图片

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

作者:hi我是大嘴巴  发布时间:2023-09-25 08:23:22 

标签:python,视频,转化,图片

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()

来源:https://blog.csdn.net/weixin_38740463/article/details/83831687

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com