使用cv2.VideoCaptu可降低fps

2024-03-28 13:12:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我有低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?在


Tags: theimageimportgetasurllibcv2frame
3条回答
# 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))

把这些线放在上面。在

你需要把这条线上移,在你的采集循环之外:

 cap = cv2.VideoCapture(0)

它只进行一次初始化。在

试着降低你的决心。你可以试试640x480。在

示例:

cap.set(CV_CAP_PROP_FRAME_WIDTH, 640)
cap.set(CV_CAP_PROP_FRAME_WIDTH, 480)

相关问题 更多 >