[libcamera-devel] [PATCH v4 00/16] More misc Python patches

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Mon May 30 16:27:06 CEST 2022


Hi,

A bunch of the patches in v3 have been merged, and this contains the
unmerged ones with the comments addressed. There's one new patch, "py:
merge read_event() and get_ready_requests()".

The doc has been moved under Documentation/ and converted to rst.

I think everything up to the examples are ready for merging (after
review).

The simple-capture and simple-continuous-capture examples have been
changed quite a bit. They are WIP, so not for merging, but I wanted to
send these as it seems we don't quite know what kind of examples we
want. And for review, I'm more looking for review of the concept than
specific lines of code.

The main change to simple-capture.py is that it now captures 30 frames,
so it shows how to requeue requests. I dropped the mmapping to simplify
it further. I think it is, in its current form, quite usable example: if
you want to capture a certain number of frames from a single camera,
this is the way I would recommend doing it.

simple-continuous-capture.py has more changes. The main diff in v3
between simple-capture.py and simple-continuous-capture.py was that the
latter used selector on the fds (stdin and libcamera). That difference
is still true, but simple-continuous-capture.py now captures from all
available cameras at the same time. It is also structured a bit more
like a real application could be structured.

While writing this I realized that "simple-continuous-capture" name no
longer works, but as I said, the examples are still WIP.

So, to summarize the examples:

- One to showcase capturing from a single camera in a very
  straightforward manner in a single function. Something you would do in
  a script when you just want to get that single job done.

- One to showcase a more complete application with event handling, stdin
  handling and multiple cameras. It would be nice to extend this to
  display the frames with Qt/KMS, but that would increase the size quite
  considerably, and we would then be moving to the cam.py-territory.

 Tomi

Tomi Valkeinen (16):
  py: unittests: Fix test_sleep()
  py: unittests: Fix test_select()
  py: cam: Move conversion funcs to helpers.py
  py: cam: Drop PIL dependency
  py: Add Request.__str__()
  py: Add FrameMetadataPlane
  py: Implement FrameBufferPlane
  py: MappedFrameBuffer: Support non-contextmanager use
  py: MappedFrameBuffer: Add 'fb' property
  py: cam: cam_qt: mmap the fbs only once
  py: merge read_event() and get_ready_requests()
  Documentation: Add python-bindings.rst
  py: examples: Add simple-capture.py
  py: examples: Add simple-continuous-capture.py
  py: examples: Add itest.py
  py: examples: Add simple-cam.py

 Documentation/index.rst                      |   1 +
 Documentation/meson.build                    |   1 +
 Documentation/python-bindings.rst            |  70 ++++
 src/py/cam/cam.py                            |   5 +-
 src/py/cam/cam_kms.py                        |   6 +-
 src/py/cam/cam_qt.py                         | 216 +++---------
 src/py/cam/cam_qtgl.py                       |   2 +-
 src/py/cam/{cam_qt.py => helpers.py}         | 154 +-------
 src/py/examples/itest.py                     | 195 +++++++++++
 src/py/examples/simple-cam.py                | 350 +++++++++++++++++++
 src/py/examples/simple-capture.py            | 162 +++++++++
 src/py/examples/simple-continuous-capture.py | 189 ++++++++++
 src/py/libcamera/py_main.cpp                 |  68 ++--
 src/py/libcamera/utils/MappedFrameBuffer.py  |  44 ++-
 test/py/unittests.py                         |  16 +-
 15 files changed, 1095 insertions(+), 384 deletions(-)
 create mode 100644 Documentation/python-bindings.rst
 copy src/py/cam/{cam_qt.py => helpers.py} (55%)
 create mode 100755 src/py/examples/itest.py
 create mode 100755 src/py/examples/simple-cam.py
 create mode 100755 src/py/examples/simple-capture.py
 create mode 100755 src/py/examples/simple-continuous-capture.py

-- 
2.34.1



More information about the libcamera-devel mailing list