Message ID | 20200918152019.784315-1-tomi.valkeinen@iki.fi |
---|---|
Headers | show |
Series |
|
Related | show |
Hi Tomi Thank you for sharing this, I think it is very interesting work. I was wondering, is there a discussion anywhere of what this Python API will look like for end users and how it would be used? You may know that Raspberry Pi has something called PiCamera which is a set of Python bindings for our existing (non-libcamera) camera stack. However, I think it's probably at a rather higher level that what is being envisaged for libcamera and therefore cannot be compared directly. But I'm definitely interested to understand more about it, and how (for example) we might build on top of it to provide something closer to what our users have been accustomed to. Thanks again! David On Fri, 18 Sep 2020 at 16:21, Tomi Valkeinen <tomi.valkeinen@iki.fi> wrote: > Hi, > > Laurent asked me to send these to get discussions about the challenges > on the list (rather than in private chats...). > > This is a prototype, RFC, hack, whatever you want to call it, but it > works for me for the small subset of features used in test.py. > > The main patch "libcamera python bindings" has some questions/issues > listed in the description, and I've added comments to the code where I'm > not sure where to go. > > There were no submodules in libcamera, so I used the same convention > I've used in kms++: ext/<submodule>. pybind11 could be added as > something that comes from the system (at least Ubuntu 20.04 has it), but > as it's header only, I think having it as a submodule is the easiest and > most manageable way to add it. > > Tomi > > Tomi Valkeinen (4): > Add pybind11 submodule > Add BoundMethodFunction > hack: Camera public destructor > libcamera python bindings > > .gitmodules | 3 + > ext/pybind11 | 1 + > include/libcamera/bound_method.h | 25 +++++ > include/libcamera/camera.h | 2 +- > include/libcamera/signal.h | 6 ++ > meson.build | 1 + > meson_options.txt | 2 + > py/meson.build | 1 + > py/pycamera/__init__.py | 29 +++++ > py/pycamera/meson.build | 35 ++++++ > py/pycamera/pymain.cpp | 169 +++++++++++++++++++++++++++++ > py/test/run-valgrind.sh | 3 + > py/test/run.sh | 3 + > py/test/test.py | 177 +++++++++++++++++++++++++++++++ > py/test/valgrind-pycamera.supp | 17 +++ > 15 files changed, 473 insertions(+), 1 deletion(-) > create mode 100644 .gitmodules > create mode 160000 ext/pybind11 > create mode 100644 py/meson.build > create mode 100644 py/pycamera/__init__.py > create mode 100644 py/pycamera/meson.build > create mode 100644 py/pycamera/pymain.cpp > create mode 100755 py/test/run-valgrind.sh > create mode 100755 py/test/run.sh > create mode 100755 py/test/test.py > create mode 100644 py/test/valgrind-pycamera.supp > > -- > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel >
Hi David, On 21/09/2020 14:08, David Plowman wrote: > Hi Tomi > > Thank you for sharing this, I think it is very interesting work. > > I was wondering, is there a discussion anywhere of what this Python API will look like for end users > and how it would be used? You may know that Raspberry Pi has something called PiCamera which is a > set of Python bindings for our existing (non-libcamera) camera stack. However, I think it's probably > at a rather higher level that what is being envisaged for libcamera and therefore cannot be compared > directly. But I'm definitely interested to understand more about it, and how (for example) we might > build on top of it to provide something closer to what our users have been accustomed to. No discussions. I don't really have a use case target for this work. I don't even have any hardware that works with libcamera, so I have just used vivid and vimc. I wanted to do something with libcamera, and as I've implemented python bindings with pybind11 to kms++ and rwmem, I thought adding basic python bindings would be an interesting project. I had a super-quick look at PiCamera some time back (I was wondering if it would give me a hint about the libcamera python API), but as you say, it seemed to be on a much higher level and I didn't look further. I agree that a higher level API would be very useful too, and I think that can be implemented with pure python. Possibly that API might need to be (at least partly) libcamera pipeline specific, although I'm just guessing here. Or maybe PiCamera could use libcamera's python API as a backend? I have no clue how it is architected, so may not be sensible. Tomi
Hi, I have continued this work, and my latest branch is available at: https://github.com/tomba/libcamera py Don't look at the history, it's full of "some work" commit messages, as I'm still experimenting with different approaches. Some of the changes since the first version: - move under src/ - add pybind11 via meson subproject - the binding covers much more of the libcamera API - simplecamera.py, an attempt to expose a single-stream simple-to-use camera class - qtest.sh, show the captured images with Qt, and show camera controls as sliders, using simplecamera.py Mainly tested with vimc, and a bit with vivid and my laptop's camera. Tomi On 18/09/2020 18:20, Tomi Valkeinen wrote: > Hi, > > Laurent asked me to send these to get discussions about the challenges > on the list (rather than in private chats...). > > This is a prototype, RFC, hack, whatever you want to call it, but it > works for me for the small subset of features used in test.py. > > The main patch "libcamera python bindings" has some questions/issues > listed in the description, and I've added comments to the code where I'm > not sure where to go. > > There were no submodules in libcamera, so I used the same convention > I've used in kms++: ext/<submodule>. pybind11 could be added as > something that comes from the system (at least Ubuntu 20.04 has it), but > as it's header only, I think having it as a submodule is the easiest and > most manageable way to add it. > > Tomi > > Tomi Valkeinen (4): > Add pybind11 submodule > Add BoundMethodFunction > hack: Camera public destructor > libcamera python bindings > > .gitmodules | 3 + > ext/pybind11 | 1 + > include/libcamera/bound_method.h | 25 +++++ > include/libcamera/camera.h | 2 +- > include/libcamera/signal.h | 6 ++ > meson.build | 1 + > meson_options.txt | 2 + > py/meson.build | 1 + > py/pycamera/__init__.py | 29 +++++ > py/pycamera/meson.build | 35 ++++++ > py/pycamera/pymain.cpp | 169 +++++++++++++++++++++++++++++ > py/test/run-valgrind.sh | 3 + > py/test/run.sh | 3 + > py/test/test.py | 177 +++++++++++++++++++++++++++++++ > py/test/valgrind-pycamera.supp | 17 +++ > 15 files changed, 473 insertions(+), 1 deletion(-) > create mode 100644 .gitmodules > create mode 160000 ext/pybind11 > create mode 100644 py/meson.build > create mode 100644 py/pycamera/__init__.py > create mode 100644 py/pycamera/meson.build > create mode 100644 py/pycamera/pymain.cpp > create mode 100755 py/test/run-valgrind.sh > create mode 100755 py/test/run.sh > create mode 100755 py/test/test.py > create mode 100644 py/test/valgrind-pycamera.supp >