Skip to content

Performance differences with libcamera native/Gstreamer and OpenCV #342

@floe

Description

@floe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions