[libcamera-devel] [PATCH v5 0/3] Python bindings

David Plowman david.plowman at raspberrypi.com
Thu Mar 17 10:44:20 CET 2022


Hi everyone

Thanks for the update!

On Mon, 14 Mar 2022 at 15:46, Tomi Valkeinen
<tomi.valkeinen at ideasonboard.com> wrote:
>
> Hi,
>
> This is v5 of the series. The changes to v4:
>
> - Changed to pybind11 'smart_holders' branch which allows us to drop the
>   HACK for Camera public destructor
> - Changed Request.set_control() so that we can drop the HACK for
>   exposing Camera from Request
> - Moved Python enum defs to a separate file for clarity
> - "Forward" declare Python classes to fix docstring issues.
>
> The set_control change breaks the current users of that function.
> Previously you could do this:
>
> req.set_control("Brightness", 1)
>
> Now you need to do:
>
> cid = camera.find_control("Brightness")
> req.set_control(cid, 1)
>

I see the need for this, and I guess it's fine - obviously we'll hide
that under our Picamera2 API as we wouldn't want our users to have to
do that!

There is one further thing I wanted to raise in relation to the Python
bindings for controls, now that a few folks are trying out Picamera2.

I've had feedback that they don't like the fact that all the "enum"
control values (exposure modes, AWB modes, that kind of thing) are
simple integers up in the Python world. They complain that this makes
them quite unfriendly to use, and I'm inclined to agree! We could
always create Python-level definitions for them, and possibly add code
to convert stuff on the fly, but I wonder if Pybind11 can do anything
more automatic for us?

Thanks!
David

>  Tomi
>
> Tomi Valkeinen (3):
>   Add Python bindings
>   py: add unittests.py
>   py: Add cam.py
>
>  meson.build                  |   1 +
>  meson_options.txt            |   5 +
>  src/meson.build              |   1 +
>  src/py/cam/cam.py            | 461 +++++++++++++++++++++++++++++++++++
>  src/py/cam/cam_kms.py        | 183 ++++++++++++++
>  src/py/cam/cam_null.py       |  46 ++++
>  src/py/cam/cam_qt.py         | 355 +++++++++++++++++++++++++++
>  src/py/cam/cam_qtgl.py       | 386 +++++++++++++++++++++++++++++
>  src/py/cam/gl_helpers.py     |  67 +++++
>  src/py/libcamera/__init__.py |  10 +
>  src/py/libcamera/meson.build |  43 ++++
>  src/py/libcamera/pyenums.cpp |  53 ++++
>  src/py/libcamera/pymain.cpp  | 453 ++++++++++++++++++++++++++++++++++
>  src/py/meson.build           |   1 +
>  src/py/test/unittests.py     | 364 +++++++++++++++++++++++++++
>  subprojects/.gitignore       |   3 +-
>  subprojects/pybind11.wrap    |   6 +
>  17 files changed, 2437 insertions(+), 1 deletion(-)
>  create mode 100755 src/py/cam/cam.py
>  create mode 100644 src/py/cam/cam_kms.py
>  create mode 100644 src/py/cam/cam_null.py
>  create mode 100644 src/py/cam/cam_qt.py
>  create mode 100644 src/py/cam/cam_qtgl.py
>  create mode 100644 src/py/cam/gl_helpers.py
>  create mode 100644 src/py/libcamera/__init__.py
>  create mode 100644 src/py/libcamera/meson.build
>  create mode 100644 src/py/libcamera/pyenums.cpp
>  create mode 100644 src/py/libcamera/pymain.cpp
>  create mode 100644 src/py/meson.build
>  create mode 100755 src/py/test/unittests.py
>  create mode 100644 subprojects/pybind11.wrap
>
> --
> 2.25.1
>


More information about the libcamera-devel mailing list