Hello,
I’ve been benchmarking camera framerate performance on TK1 using OV5640 camera module.
Using Gstream with the following pipeline:
time -v gst-launch-0.10 v4l2src device=/dev/video0 num-buffers=100 ! 'video/x-raw-yuv,format=(fourcc)UYVY,width=1920,height=1080' ! fakesink
I achieve about 28fps for 1080p resolution which corresponds to the camera specifications. However, with OpenCV camera achieves only 15fps.
I use OpenCV built through Yocto with:
IMAGE_INSTALL_append = " opencv"
and use the following code to measure framerate:
// Open and config camera
cv::VideoCapture cap;
cap.open("/dev/video0");
cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
// Discard first 10 images to stabilize capture
cv::Mat frame;
for(int i=0; i<10; ++i) {
cap >> frame;
}
// Measure FPS
const int count = 20;
for(int i=0; i<count; ++i) {
start = std::chrono::high_resolution_clock::now();
cap.grab();
finish_capture = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_capture = finish_capture - start;
std::cout << elapsed_capture.count() << " s. Fps (capture): " << (1.0/elapsed_capture.count()) << "\n";
}
Do you have any idea, why OpenCV performs worse than Gstreamer and how could framerate in OpenCV be improved?