视频提取
import cv2 import matplotlib as plt import numpy as py #cv2.VideoCapture可捕获摄像头用数字控制不同设备,如0,1 #如果是视频文件直接指定路径即可。 vc=cv2.VideoCapture('C:/Users/59925/Desktop/pytest/video/video_minions.mp4') if vc.isOpened(): #判断图像是否打开 boolean,frame=vc.read() else: boolean=False while boolean: #通过一帧一帧图像方式读取视频 b,frame=vc.read() if b == False:#if frame is None: break else: gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) #把BGR图转化成才彩色图 cv2.imshow('video',gray) #若cv2.waitKey(1),则以电脑最高速度运行帧, #cv2.waitKey(10)&0xFF,表示只截取读取到ASCII码后8位。壁面其他按键干扰 if cv2.waitKey(10)&0xFF==27:#按下键盘按键Esc退出 break vc.release() #释放摄像头 cv2.destroyAllWindows() #关闭窗口
标签:视频,vc,提取,frame,cv2,opencv,boolean,video,import From: https://www.cnblogs.com/tanyuanqing/p/17478031.html