Hi!
I need to capture video from a camera in a resolution of 1920x1080 with the highest possible frame rate, and then work with the resulting image in opencv.
Using arducamstill
I get the maximum possible 60 FPS, however when using capture2opencv
the frame rate is about 10 FPS.
To understand why this is happening, I wrote a small project based on capture2opencv
, where I simply get an image from the camera and write it to cv::Mat
using the get_image()
function without displaying it through cv::imshow()
. I measured the frame rate and got about 20 FPS.
I managed to figure out that this is happening because of the cv::cvtColor(*image, *image, cv::COLOR_YUV2BGR_I420)
in the get_image()
function. Removing this conversion, I get 16 ms to capture one frame, with it - 49 ms. Thus, on RPI4, this function takes 33 ms, which, in my opinion, is a very long time. Hence, the drop in the frame rate is exactly 3 times, since two frames are simply lost (I tried to depict it in the diagram).
Question: is it possible to somehow solve this problem? Speed up cvtColor()
execution or avoid using it altogether?
P.S. OpenCV is compiled with TBB, while the program is running with the cvtColor()
function, all 4 cores are used.