Hi everyone,
this is not per se a libcamera issue, but I couldn't find a better place to ask (no obvious libcamera discussion forum, e.g.). Anyway.
I'm building a custom OpenCV-based computer vision application on a Raspberry Pi 4. I have until recently used the OpenCV Gstreamer video source with a stub pipeline just containing libcamerasrc ! appsink to get frames from the camera, but I wanted to improve the performance a bit and also have more control over the camera directly, so I wrote a native C++ libcamera adapter that outputs OpenCV Mat objects.
Both the native adapter as well as the OpenCV Gstreamer source work fine, but there are noticeable performance differences: with the Gstreamer source, I get 15 FPS as requested by the pipeline; with the native adapter, I only get 10 FPS. Moreover, the CPU load with the Gstreamer source is around 160% (ca 1.6 cores), while it is almost 400% with the native libcamera adapter (all cores maxed out). I'm particularly confused about the second part, as I was assuming that libcamera only starts one internal thread, but there seem to be at the very least two extra threads running? My adapter is mostly based on the example from the libcamera documentation, code is here if it helps: https://github.com/floe/surfacestreams/blob/main/src/Libcamera.cpp
Thanks and best, Florian
Hi everyone,
this is not per se a libcamera issue, but I couldn't find a better place to ask (no obvious libcamera discussion forum, e.g.). Anyway.
I'm building a custom OpenCV-based computer vision application on a Raspberry Pi 4. I have until recently used the OpenCV Gstreamer video source with a stub pipeline just containing
libcamerasrc ! appsinkto get frames from the camera, but I wanted to improve the performance a bit and also have more control over the camera directly, so I wrote a native C++ libcamera adapter that outputs OpenCVMatobjects.Both the native adapter as well as the OpenCV Gstreamer source work fine, but there are noticeable performance differences: with the Gstreamer source, I get 15 FPS as requested by the pipeline; with the native adapter, I only get 10 FPS. Moreover, the CPU load with the Gstreamer source is around 160% (ca 1.6 cores), while it is almost 400% with the native libcamera adapter (all cores maxed out). I'm particularly confused about the second part, as I was assuming that libcamera only starts one internal thread, but there seem to be at the very least two extra threads running? My adapter is mostly based on the example from the libcamera documentation, code is here if it helps: https://github.com/floe/surfacestreams/blob/main/src/Libcamera.cpp
Thanks and best, Florian