[libcamera-devel] [RFC v3 4/5] Add Python bindings
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Dec 10 14:15:31 CET 2021
Hi Tomi,
On Fri, Dec 10, 2021 at 02:27:59PM +0200, Tomi Valkeinen wrote:
> 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.
I have to say I lack experience in this area, but PyCamera C++ wrapper class
sounds like it could really help. I expect it would expose a function to
retrieve the Camera pointer, and I wonder if exposing that using a
custom `operator Camera *()` could help interfacing with code that
expects a Camera pointer, or if there are better ways. I'm sure we're
not the only ones dealing with this.
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list