编程语言
首页 > 编程语言> > opencv 捕获摄像头 python

opencv 捕获摄像头 python

作者:互联网

#该代码是捕获10S的视频信息
import cv2

cameraCapture = cv2.VideoCapture(0)
fps = 30
size = (int(cameraCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),
		int(cameraCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))

#编解码器使用的是cv2.VideoWriter_fourcc('I','4','2','0')
videoWriter = cv2.VideoWriter('MyOutputVid.avi',cv2.VideoWriter_fourcc('I','4','2','0'),fps,size)

success,frame = cameraCapture.read()
numFramesRemaining = 10 * fps - 1
while success and numFramesRemaining > 0:
	videoWriter.write(frame)
	success, frame = cameraCapture.read()
	numFramesRemaining -= 1
cameraCapture.release()

 

标签:success,python,frame,cv2,cameraCapture,opencv,fps,摄像头,VideoWriter
来源: https://blog.csdn.net/sinat_38685910/article/details/94480498