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

 

上一篇:yolov3保存视频


下一篇:Origin C创建视频