From patchwork Mon May 30 14:27:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16107 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1FC7EBD161 for ; Mon, 30 May 2022 14:27:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DBB2D65636; Mon, 30 May 2022 16:27:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653920860; bh=E1zCkiTpFdAZNbHvcBCJYLdkY3Kf0Gzhi5GdzQkTGbk=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FlG4vV42WdEml9KOPjQlg/Ex4KT+jjPvTr0oo/PeAueFROujObfJhxVWNBwusfq+f D+Jn7EuRV6dZiENsUUcLVBndCW3IkZrGzg9VVkPkL5f43OnLjRXlSkDjyJV27kAz2V K6t5dPQuNq4CTmHXh5atEApfZMUmvnM7fBkNO9h0gwF6uEq9iyMbK9HtAAhTkX0EBh 2H1aktVdE67DweW+5se42rC762rRLWYwb+dUZJ8qfr776290aGJv71brG1VbwStdLt 6kBn/RB/rvVdgW340IlQM59VlkAzVxFI5An8UHdMuQPZfU3G4Ht48jD0Tk6tE04ttc 6My3xdbfA7hNA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 787DC60411 for ; Mon, 30 May 2022 16:27:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EbI1tVyc"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2E796BD; Mon, 30 May 2022 16:27:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653920859; bh=E1zCkiTpFdAZNbHvcBCJYLdkY3Kf0Gzhi5GdzQkTGbk=; h=From:To:Cc:Subject:Date:From; b=EbI1tVycx4VwQOkzLDJlyVO/P8VOxesZXUZTSIq3P7M/WuQ7NeAZnsOFa8NbfyLNI X1nzFFtN6dmeROGBIz4HZLwa6FwoFEH9TbcRX339l5Z5Krpm0dB53xm92T0ynIyCvN VQ716o+VItpB+33Ami5jVdmzt0KzEtAxZfRxLWSA= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Mon, 30 May 2022 17:27:06 +0300 Message-Id: <20220530142722.57618-1-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 00/16] More misc Python patches X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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