import cv2
camerac = cv2.VideoCapture(0) #获取摄像头的帧流
fps = 30 #设定帧率
size = (int(camerac.get(cv2.CAP_PROP_FRAME_WIDTH)), int(camerac.get(cv2.CAP_PROP_FRAME_HEIGHT))) #设定视频宽高
vw = cv2.VideoWriter(
"../video/2_camera.avi",
cv2.VideoWriter_fourcc("I", "4", "2", "0"),
fps,
size
)
success, frame = camerac.read()
numframe_save = 10 * fps - 1 #总共保存多少帧
while success and numframe_save >= 0:
vw.write(frame)
success, frame = camerac.read()
numframe_save -= 1
camerac.release()
opencv获取摄像头帧流
最新推荐文章于 2024-04-18 08:38:48 发布