python - 使用 cv2.VideoCapture 降低 fps
问题描述
我的 FPB 较低 ~5,我在不同的相机罗技 c270 和罗技 9000 上检查了此代码,情况相同。
我完成了关于关闭右灯等的所有提示。
import urllib.request as urllib
import cv2
import numpy as np
import time
while True:
# Use urllib to get the image and convert into a cv2 usable format
cap = cv2.VideoCapture(0)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
hiegh = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
ret, frame = cap.read()
# put the image on screen
cv2.imshow('Webcam', frame)
if cv2.waitKey(1) & 0xFF == 27:
break
cap.release()
cv2.destroyAllWindows()
我应该怎么做才能增加FPS?
解决方案
您需要将这条线向上移动,在您的采集循环之外:
cap = cv2.VideoCapture(0)
它只进行一次初始化。
推荐阅读
- matrix - Octave / MATLAB中的快速矩阵求和?
- autohotkey - AutoHotKey 发送热键
- apache-spark - 使用没有整数列的 Spark(并行)从关系数据库中提取数据?
- c# - WinSCP .net 程序集不遵守包含文件掩码
- asp.net - SQL Server Express 连接到 .mdf 文件
- xamarin.forms - 如何使用 Appium/Cucumber for Xamarin Forms 构建 E2E 测试?
- java - 如何防止自动生成评论只是为了快速修复 serialVersionUID 警告?
- javascript - 带有引导程序的冰沙图表
- node.js - 将 ncp 与 Node 一起使用,不会复制任何文件或文件夹
- hl7 - 任何与设备制造商或型号相关的 HL7 V2 字段?