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

猜你喜欢

转载自blog.csdn.net/sinat_38685910/article/details/94480498
今日推荐