[libcamera-devel] [RFC v3 4/5] Add Python bindings

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Fri Dec 10 13:27:59 CET 2021


On 09/12/2021 21:28, Laurent Pinchart wrote:

>>>>> +               .def_property_readonly("efd", [](CameraManager &) {
>>>>> +                       return g_eventfd;
>>>>> +               })
> 
> I understand why this is needed (documentation is required though), but
> why is the eventfd exposed by the CameraManager class and not the Camera
> class ? Moving it to Camera would also allow moving the requests lists
> there, and making them member variables instead of global variables.

Because g_eventfd is a global variable and CameraManager is a singleton.

We don't have CameraManger or Camera classes in the python bindings, in 
the sense that we could add fields to them. There's no 
python-bindings-specific-state for class instances. In other words, 
eventfd is not part of CameraManager, it's just accessed via it.

I've struggled with this multiple times, and I haven't figured out a 
simple solution.

We can build new C++ classes that wrap the libcamera C++ classes, say, 
PyCamera for Camera, but then that affects all the places in the 
bindings where Camera instance is handled, producing possibly quite a 
bit of extra code. I haven't tried this out, but it's been in my mind as 
it would solve some problems.

  Tomi


More information about the libcamera-devel mailing list