python - 通过使用 cv2.VideoCapture 降低 fps

标签 python opencv camera frame-rate

我的 FPB 很低~5,我在不同的相机 logitech c270 和 logitech 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)

它只进行一次性初始化。

关于python - 通过使用 cv2.VideoCapture 降低 fps,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54249824/

相关文章:

java - Tomcat 中 OpenCV 的 UnsatisfiedLinkError

android - 使用 CWAC 相机预览尺寸

javascript - Threejs相机绕原点旋转

python - python 中函数参数的命名约定

python - 什么是 get-pip.py 校验和?我在哪里可以确定?

python - 网页抓取 : request not returning complete content of the webpage

video - 用 flutter 捕捉视频

python - Apache 与扭曲

python - 在 Python 请求模块中处理自动重定向

opencv - 尝试构建暗网时出现 "opencv2: no such file or directory"?