[{"id":23235,"web_url":"https://patchwork.libcamera.org/comment/23235/","msgid":"<YpSOw8b2bbjwlbwy@pendragon.ideasonboard.com>","date":"2022-05-30T09:30:43","subject":"Re: [libcamera-devel] [PATCH v3 11/30] py: Add README.md","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nThank you for the patch.\n\nOn Fri, May 27, 2022 at 05:44:28PM +0300, Tomi Valkeinen wrote:\n> Add a basic README for the Python bindings. While not a proper doc, the\n> README and the examples should give enough guidance for users who are\n> somewhat familiar with libcamera.\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/py/README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++\n\nAs discussed in the review of v2, would it be much work to convert this\nto .rst and move it to Documentation/ ?\n\n>  1 file changed, 60 insertions(+)\n>  create mode 100644 src/py/README.md\n> \n> diff --git a/src/py/README.md b/src/py/README.md\n> new file mode 100644\n> index 00000000..74a8cd9f\n> --- /dev/null\n> +++ b/src/py/README.md\n> @@ -0,0 +1,60 @@\n> +# Python Bindings for libcamera\n> +\n> +*WARNING* The bindings are under work, and the API will change.\n> +\n> +## Differences to the C++ API\n> +\n> +As a rule of thumb the bindings try to follow the C++ API when possible. This\n> +chapter lists the differences.\n> +\n> +Mostly these differences fall under two categories:\n> +\n> +1. Differences caused by the inherent differences between C++ and Python.\n> +These differences are usually caused by the use of threads or differences in\n> +C++ vs Python memory management.\n> +\n> +2. Differences caused by the code being work-in-progress. It's not always\n> +trivial to create a binding in a satisfying way, and the current bindings\n> +contain simplified versions of the C++ API just to get forward. These\n> +differences are expected to eventually go away.\n> +\n> +### Coding Style\n> +\n> +The C++ code for the bindings follows the libcamera coding style as much as\n> +possible. Note that the indentation does not quite follow the clang-format\n> +style, as clang-format makes a mess of the style used.\n> +\n> +The API visible to the Python side follows the Python style as much as possible.\n> +\n> +This means that e.g. `Camera::generateConfiguration` maps to\n> +`Camera.generate_configuration`.\n> +\n> +### CameraManager\n> +\n> +The Python API provides a singleton CameraManager via `CameraManager.singleton()`.\n> +There is no need to start or stop the CameraManager.\n> +\n> +### Handling Completed Requests\n> +\n> +The Python bindings do not expose the Camera::requestCompleted signal\n> +directly as the signal is invoked from another thread and it has real-time\n> +constraints. Instead the bindings will internally queue the completed\n> +requests and use an eventfd to inform the user that there are completed\n> +requests.\n> +\n> +The user can wait on the eventfd, and upon getting an event, use\n> +CameraManager.read_event() to clear the eventfd event and\n> +CameraManager.get_ready_requests() to get the completed requests.\n> +\n> +### Controls & Properties\n> +\n> +The classes related to controls and properties are rather complex to implement\n> +directly in the Python bindings. There are some simplifications on the Python\n> +bindings:\n> +\n> +- There is no ControlValue class. Python objects are automatically converted\n> +  to ControlValues and vice versa.\n> +- There is no ControlList class. A python dict with ControlId keys and python\n> +  object values is used instead.\n> +- There is no ControlInfoMap class. A python dict with ControlId keys and\n> +  ControlInfo values is used instead.","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CDB50BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 May 2022 09:30:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B44165633;\n\tMon, 30 May 2022 11:30:47 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B0826040B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 May 2022 11:30:46 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(lmontsouris-659-1-41-236.w92-154.abo.wanadoo.fr [92.154.76.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E02676BD;\n\tMon, 30 May 2022 11:30:45 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653903047;\n\tbh=xzIbt8GcOtnSewv2D3DZgzLcbm+SRUbICHuNsoiXqRc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=4ORAwdk24D7JM5s1Q7lJpX5zUJdp6MA3+aNzDhaE4X8ffjws0cBaJ9Ee5/RXHM5aV\n\tsyVZsLZDG5DEhzWq6DvxdwE5h6isKLZLK/au+H5SD+wvnpvQlMJSoGoTvk+I5xHCNK\n\trw6h/K3AkhvpgbkTw4ouYUwxWyc7qkXQJMpJWCnAkRt7nsAXtHyopjRrIwwO12V9Wb\n\tYXIZnJm/UHy/BwTvlvulIO5A2yFdtDQjTHkqYbvpX/1yd2Yz6SAwFnYjeGjKhl/3Pm\n\t+KXzu44jpm95AknkzoWuuumk1XYgkHP1MwUk+cukfUeY08sjPero8KoEJfeF6UeSoa\n\tl3vSD5SF9LG1A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653903046;\n\tbh=xzIbt8GcOtnSewv2D3DZgzLcbm+SRUbICHuNsoiXqRc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Lr2pH/HDzjgUGRj82FX6vocCP55f8A1dkQn2DwuvKW5mLLc7xLv3N2oR50mspLstn\n\tSokaqWgholP+PSBdPRPp7of87PVeTCfvGc6F/iDDf+xe3/7J+OltZbHhk94PW26zZv\n\t66Vh5eB9BtFvEro12GUJorKKRS+nH3RQT/qIHfDw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Lr2pH/HD\"; dkim-atps=neutral","Date":"Mon, 30 May 2022 12:30:43 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<YpSOw8b2bbjwlbwy@pendragon.ideasonboard.com>","References":"<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>\n\t<20220527144447.94891-12-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220527144447.94891-12-tomi.valkeinen@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 11/30] py: Add README.md","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23240,"web_url":"https://patchwork.libcamera.org/comment/23240/","msgid":"<12aa53b4-5978-3878-48e0-21efeb1d70a3@ideasonboard.com>","date":"2022-05-30T09:46:15","subject":"Re: [libcamera-devel] [PATCH v3 11/30] py: Add README.md","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"On 30/05/2022 12:30, Laurent Pinchart wrote:\n> Hi Tomi,\n> \n> Thank you for the patch.\n> \n> On Fri, May 27, 2022 at 05:44:28PM +0300, Tomi Valkeinen wrote:\n>> Add a basic README for the Python bindings. While not a proper doc, the\n>> README and the examples should give enough guidance for users who are\n>> somewhat familiar with libcamera.\n>>\n>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> ---\n>>   src/py/README.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++\n> \n> As discussed in the review of v2, would it be much work to convert this\n> to .rst and move it to Documentation/ ?\n\nYes, I've done that for v4.\n\n  Tomi","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C8D45BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 May 2022 09:46:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8B1F865633;\n\tMon, 30 May 2022 11:46:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A583E6040B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 May 2022 11:46:18 +0200 (CEST)","from [192.168.1.111] (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 38A076BD;\n\tMon, 30 May 2022 11:46:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653903979;\n\tbh=79krPDUkChgA7ov496+k2mvZNQvUoNRaIj2eYniRzxE=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=fiUyFdxh2NmIJP7vycMuQC6ncG+13W9Ye3BkD50s/Ib90zZOaf79ywpdOFli2gzfF\n\tM9h5wywGl2w81Lwpr6i3eZzlCen18RF9GDfX2yPk9ab2TFF5382Ifw1xP/nVcyHQlu\n\tjLBYGKHrc3DzRWwv/cHGWxvpb/QDuGwpcnQwyLKmBpAu57tCNm6l2PxDwPSSYnGUKs\n\tCE6rq+hJchxXWPQ5QBRlmqkjMJ9xf2Gy6UJVNmD6Zw5oac2qa4olP4R+EhP5zXNA4p\n\t7KLmkXNI8z/rOZtHxBLDdzslDhRMJpXs2alg8GV0XAfRrpSkpq1a9yFwSYCItzumKi\n\tfXt4cSQomWX5A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653903978;\n\tbh=79krPDUkChgA7ov496+k2mvZNQvUoNRaIj2eYniRzxE=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=v/eUO8PDI3utiSyBJg2/Hpki8sAvETS4OAdnF63rJO+0/5L9K3/QAfj24YyaIuXmo\n\t10Pdy5CCUvHztozaqANYmyqHsIZqVeF8tBF78clJldU8tN24gBG5/nojncGEljlvM+\n\tvDBiy/wilqO2BkSsqEJwE9U8NKcTTz/A/hQUpq3A="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"v/eUO8PD\"; dkim-atps=neutral","Message-ID":"<12aa53b4-5978-3878-48e0-21efeb1d70a3@ideasonboard.com>","Date":"Mon, 30 May 2022 12:46:15 +0300","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.9.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>\n\t<20220527144447.94891-12-tomi.valkeinen@ideasonboard.com>\n\t<YpSOw8b2bbjwlbwy@pendragon.ideasonboard.com>","In-Reply-To":"<YpSOw8b2bbjwlbwy@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 11/30] py: Add README.md","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]