From patchwork Fri Nov 27 13:37:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 10515 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 5FC2BBE176 for ; Fri, 27 Nov 2020 13:37:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DAEDF63470; Fri, 27 Nov 2020 14:37:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="J2m0VtWl"; dkim-atps=neutral Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CA545632EE for ; Fri, 27 Nov 2020 14:37:57 +0100 (CET) Received: by mail-lf1-x12e.google.com with SMTP id d20so7049894lfe.11 for ; Fri, 27 Nov 2020 05:37:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S7DTAGg+Rnwaz+fYTbm5QhnIQDCJ8kGR1Kx3UP0xdiY=; b=J2m0VtWlllLCYPMsMsa9unRzcIxzpfN7cOwrSJvKA9imsEyLH3ZfOxK4HdGzSwhpLB TTA8p+p89vXnQ/e4SXB6El5OaYMTx/GS8rKv6R5WPcoNH/G+mXkiMBXeSvixf41a02Ov cSYm9/T3pf4/5houCkEWx3qqrE4jgxzcGh1RdIA7vc6Hx+r78Vwzz7gkG3RtXX6uznZ+ TKMZW6o16i6SSwYQTXMizt5r8tPg6uwSViqTUXUHBC6ayL5yGyL3WG8Q48vj/YGGPODL XxRf/PNqS45xX3zlvMvsGRJuAwKgS9AFif4T6FGzuLYxs/i7Oe17c/tk2Akh43rdpX7d hw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=S7DTAGg+Rnwaz+fYTbm5QhnIQDCJ8kGR1Kx3UP0xdiY=; b=ikMr2cNzyXh85zxz/onZ9aJ35W2MCVwPGpVJBJpWGTvqcIP1ANOpDvmfoewlRskYNu tugum2i/tNCqlN0Buyk5kIlWAtOndvVeCjJ4R22Y35qPygUVIxDUFnlXNPi5hLZ/ZVDw 2PX2QXyEXfcF9Ux7trklhH0zK7tAjUyqkbx76vCeDLYJvzS7HthOtlluINbbSd5aQ4C6 1eTVAFTZ1QErtrvSVJbWl1Kt/uqbCXwi5LRly9i8PojLMdqTwhmQrjpF6eQpKmGr/XRc GVQ9yYvl4wIeqjA7cpuSiZOpzqQUNJJoN/1obA9ThUgMs2Lw8ySmOTCvRjBjNV9tZ2J9 IyRA== X-Gm-Message-State: AOAM53359LGWYL6rMieplAmpUv8O7IyYB4hBDpRrNxGHXnl5+1z8iZ2F jC9u9WBThIvivDxkZgkECXLqnRf+A10= X-Google-Smtp-Source: ABdhPJzJumx501yqEaN6aODtM/ntbmI/a1LqbDjUImS2SDlXSfp5eOBFN/USshZstJBU8WxICBP43w== X-Received: by 2002:a19:22c9:: with SMTP id i192mr3685935lfi.65.1606484276901; Fri, 27 Nov 2020 05:37:56 -0800 (PST) Received: from deskari.ti.com (91-152-83-50.elisa-laajakaista.fi. [91.152.83.50]) by smtp.gmail.com with ESMTPSA id z199sm690892lfc.42.2020.11.27.05.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2020 05:37:56 -0800 (PST) From: Tomi Valkeinen To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Nov 2020 15:37:34 +0200 Message-Id: <20201127133738.880859-1-tomi.valkeinen@iki.fi> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC v2 0/4] prototype python bindings 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: , Cc: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi, It's been a while since the v1 RFC, and even if I haven't had much time to work on this, I thought it's time to send a new version, at least to avoid anyone testing the old one. Too many changes to v1 to mention them all (not that I even remember...), but a few here: - Use meson subprojects for pybind11. The public subproject repository didn't have a recent pybind11, so I have pybind11 2.6.0 packaged here in a separate patch. - Use eventfd to convey events from C++ to Python. This gets rid of multiple issues, e.g. the locking problems and the callback subscriptions. - simplecamera.py: a "simple" camera class which hopefully makes libcamera more natural to use from python (compared to the very c++ like API that the basic bindings provide). - Some new tests: * test.py: simple test that just captures frames and exists * drmtest.py: uses kms++ python bindings to show the captured images on screen. * icam.py: Meant to run in an interactive python session. Uses Qt to * show (possibly from multiple cameras) captured images. One can adjust the cameras & controls via the python shell. Some clear issues are still present: - Memory management, especially related to Requests and FBs is still not clear. - Not all control types are supported. - There are open parts in the SimpleCamera config sequences. It must be simple, but you also have to be able to do everything, and at the moment it's a bit of a mess. This is not a request to review as such, as I know there are plenty of things to fix. I think the best feedback would be on the area of thoughts about the API in general, or ideas on how to solve the issues. Tomi Tomi Valkeinen (4): hack: Camera public destructor HACK: expose Camera* from Request libcamera python bindings py: update pybind11 wrap to 2.6.0 .gitignore | 2 + include/libcamera/camera.h | 2 +- include/libcamera/request.h | 1 + meson_options.txt | 2 + src/libcamera/request.cpp | 5 + src/meson.build | 1 + src/py/meson.build | 1 + src/py/pycamera/__init__.py | 11 + src/py/pycamera/meson.build | 38 ++ src/py/pycamera/pymain.cpp | 382 ++++++++++++++++++ src/py/test/drmtest.py | 129 ++++++ src/py/test/icam.py | 154 +++++++ src/py/test/run-valgrind.sh | 6 + src/py/test/run.sh | 3 + src/py/test/simplecamera.py | 198 +++++++++ src/py/test/test.py | 210 ++++++++++ src/py/test/valgrind-pycamera.supp | 17 + .../packagecache/pybind11-2.6.0-wrap.zip | Bin 0 -> 1456 bytes subprojects/packagecache/pybind11-2.6.0.zip | Bin 0 -> 727287 bytes subprojects/pybind11.wrap | 10 + 20 files changed, 1171 insertions(+), 1 deletion(-) create mode 100644 src/py/meson.build create mode 100644 src/py/pycamera/__init__.py create mode 100644 src/py/pycamera/meson.build create mode 100644 src/py/pycamera/pymain.cpp create mode 100755 src/py/test/drmtest.py create mode 100755 src/py/test/icam.py create mode 100755 src/py/test/run-valgrind.sh create mode 100755 src/py/test/run.sh create mode 100644 src/py/test/simplecamera.py create mode 100755 src/py/test/test.py create mode 100644 src/py/test/valgrind-pycamera.supp create mode 100644 subprojects/packagecache/pybind11-2.6.0-wrap.zip create mode 100644 subprojects/packagecache/pybind11-2.6.0.zip create mode 100644 subprojects/pybind11.wrap