Hey guys. I am experiencing some problems with really slow framerate when using OpenCV to display a video stream. My code is as simple as it gets. But still, when I try to display HD the entire stream bogs down to ~ 1FPS. If I run tegrastats I can see that all four CPU’s are running at around 60% (average)
Why is this? This is the simplest task ever. Why is it so slow?
Thanks!
Code:
#include <opencv2/imgproc/imgproc.hpp>
#include <stdio.h>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
Mat image1, image2;
int k, i;
const char* right_cam_gst = "nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM),\
width=(int)1280,\
height=(int)720,\
format=(string)I420,\
framerate=(fraction)60/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);
namedWindow("window",WINDOW_NORMAL);
for (;;)
{
const clock_t begin_time = clock();
cap1 >> image1;
imshow("window", image1);
if(waitKey(1) == 27)
break;
cout << float( clock () - begin_time ) / CLOCKS_PER_SEC << "\n" << std::flush;
}
}