使用 OpenCV VideoCapture 的低 FPS

Low FPS with OpenCV VideoCapture

我正在尝试使用 OpenCV 显示视频流,但我在帧率方面遇到了可怕的问题。我的视频源最多可以输出 60 fps,但我将其限制为 30。问题是我以大约 2fps 的速度接收它

我已尽可能简化我的程序以使其更易于阅读:

#include "opencv2/core/core.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>

using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{


    Mat image1;
    int k;

     const char* right_cam_gst = "nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM),\
                                              width=(int)640,\
                                              height=(int)360,\
                                              format=(string)I420,\
                                              framerate=(fraction)30/1 ! nvvidconv flip-method=2 ! video/x-raw,\
                                              format=(string)I420 ! videoconvert ! video/x-raw,\
                                              format=(string)BGR ! appsink";



    VideoCapture cap1 = VideoCapture(right_cam_gst);




   for (;;)
    {
       cap1 >> image1;

       imshow("image1", image1);

       if(waitKey(1) == 27)
        break;
    }

}

这应该以流允许的速度抓取并显示图像。对吗?

感谢大家的帮助!

EDIT 看起来如果我只是尽可能快地显示图像,它只能以大约 1fps 的速度显示。这完全消除了相机。

系统: ubuntu nvidia Jetson TX1

找到答案了!看起来即使我的以太网连接速度很快,它还是以某种方式使用服务器进行计算。 (不确定如何)。看到这个 post:https://devtalk.nvidia.com/default/topic/1025856/very-slow-framerate-jetson-tx1-and-opencv/?offset=8

我禁用了 Xserver 并直接插入,我得到了完整的 60 FPS。