[{"id":35843,"web_url":"https://patchwork.libcamera.org/comment/35843/","msgid":"<20250916133445.GA1875@pendragon.ideasonboard.com>","date":"2025-09-16T13:34:45","subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Tue, Sep 16, 2025 at 03:31:53PM +0200, Stefan Klug wrote:\n> In commit b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with\n> span in constructor\") the FrameBuffer::planes() function was modified to\n> return a Span instead of a vector. This leads to the following runtime\n> exception in the python binding:\n> \n> TypeError: Unregistered type : libcamera::Span<libcamera::FrameBuffer::Plane const, 18446744073709551615ul>\n> \n> Fix that by manually converting the Span to a vector.\n> \n> Note: The best solution would be to implement a Span type caster for\n> pybind11. But implementing and testing that properly is a bit more\n> involved than expected. As we don't need bidirectional mapping, the same\n> workaround as for FrameMetadata::planes() was used for now.\n\n\"use the same workaround as for FrameMetadata::planes() for now\"\n\n> Fixes: b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with span in constructor\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/py/libcamera/py_main.cpp | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> index 441a70ab4d5e..70245ec78f9a 100644\n> --- a/src/py/libcamera/py_main.cpp\n> +++ b/src/py/libcamera/py_main.cpp\n> @@ -372,7 +372,13 @@ PYBIND11_MODULE(_libcamera, m)\n>  \t\t.def(py::init<std::vector<FrameBuffer::Plane>, unsigned int>(),\n>  \t\t     py::arg(\"planes\"), py::arg(\"cookie\") = 0)\n>  \t\t.def_property_readonly(\"metadata\", &FrameBuffer::metadata, py::return_value_policy::reference_internal)\n> -\t\t.def_property_readonly(\"planes\", &FrameBuffer::planes)\n> +\t\t.def_property_readonly(\"planes\", [](const FrameBuffer &self) {\n> +\t\t\t/* Convert from Span<> to std::vector<> */\n> +\t\t\t/* Note: this creates copies */\n> +\t\t\tstd::vector<FrameBuffer::Plane> v(self.planes().begin(),\n> +\t\t\t\t\t\t\t  self.planes().end());\n> +\t\t\treturn v;\n> +\t\t})\n>  \t\t.def_property(\"cookie\", &FrameBuffer::cookie, &FrameBuffer::setCookie);\n>  \n>  \tpyFrameBufferPlane","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 642ABC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Sep 2025 13:35:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0909D69375;\n\tTue, 16 Sep 2025 15:35:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8986869375\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Sep 2025 15:35:13 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 09E28DF3;\n\tTue, 16 Sep 2025 15:33:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AYAuw9ry\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758029635;\n\tbh=z2nLDYv9IYHH31T7cRlR2SgwopWGa59W5ycJXUBgcBc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AYAuw9ry+55KqNNkx3Xl88+I8lh8qqEWpiJ+oWs9RTOxdUEn2Fs1M+/AZPX6dG8x8\n\taLClype1H1x1Ruzxd1kaHUR0lnQ1XAgB0kqm0Ex+8huRX32kRUdeVu1GRFAbQoHdJ1\n\tfN6e2kkPJs8RI3EpEVifSU8npVc5Bmd0cgERahu0=","Date":"Tue, 16 Sep 2025 16:34:45 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","Message-ID":"<20250916133445.GA1875@pendragon.ideasonboard.com>","References":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35845,"web_url":"https://patchwork.libcamera.org/comment/35845/","msgid":"<175802990822.1246375.4921288643544715479@ping.linuxembedded.co.uk>","date":"2025-09-16T13:38:28","subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-09-16 14:34:45)\n> On Tue, Sep 16, 2025 at 03:31:53PM +0200, Stefan Klug wrote:\n> > In commit b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with\n> > span in constructor\") the FrameBuffer::planes() function was modified to\n> > return a Span instead of a vector. This leads to the following runtime\n> > exception in the python binding:\n> > \n> > TypeError: Unregistered type : libcamera::Span<libcamera::FrameBuffer::Plane const, 18446744073709551615ul>\n> > \n> > Fix that by manually converting the Span to a vector.\n> > \n> > Note: The best solution would be to implement a Span type caster for\n> > pybind11. But implementing and testing that properly is a bit more\n> > involved than expected. As we don't need bidirectional mapping, the same\n> > workaround as for FrameMetadata::planes() was used for now.\n> \n> \"use the same workaround as for FrameMetadata::planes() for now\"\n> \n> > Fixes: b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with span in constructor\")\n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> > ---\n> >  src/py/libcamera/py_main.cpp | 8 +++++++-\n> >  1 file changed, 7 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> > index 441a70ab4d5e..70245ec78f9a 100644\n> > --- a/src/py/libcamera/py_main.cpp\n> > +++ b/src/py/libcamera/py_main.cpp\n> > @@ -372,7 +372,13 @@ PYBIND11_MODULE(_libcamera, m)\n> >               .def(py::init<std::vector<FrameBuffer::Plane>, unsigned int>(),\n> >                    py::arg(\"planes\"), py::arg(\"cookie\") = 0)\n> >               .def_property_readonly(\"metadata\", &FrameBuffer::metadata, py::return_value_policy::reference_internal)\n> > -             .def_property_readonly(\"planes\", &FrameBuffer::planes)\n> > +             .def_property_readonly(\"planes\", [](const FrameBuffer &self) {\n> > +                     /* Convert from Span<> to std::vector<> */\n> > +                     /* Note: this creates copies */\n> > +                     std::vector<FrameBuffer::Plane> v(self.planes().begin(),\n> > +                                                       self.planes().end());\n> > +                     return v;\n> > +             })\n> >               .def_property(\"cookie\", &FrameBuffer::cookie, &FrameBuffer::setCookie);\n> >  \n> >       pyFrameBufferPlane\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 E2B18BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Sep 2025 13:38:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DAF80613A1;\n\tTue, 16 Sep 2025 15:38:32 +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 6C57A613A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Sep 2025 15:38:31 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 01940E8A;\n\tTue, 16 Sep 2025 15:37:12 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cpBgGhk+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758029833;\n\tbh=oEhgPqcxpik9tIPJ783V0Om9cqIrqJOZOVZWP8Sf3So=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=cpBgGhk+CvOl+hM93X3rRieOfLnxLuXbsAoWbUq4ljp1smQb5FBaOOazWH5nIraT0\n\tQbXYNRn1/NrHIbOaQ1q5HY44Zivaqu/WzLipXcQgmFuHIskkCMjZ9GDNjyTzGg6w+O\n\tX40BiP0A0eNI3Ih/qbFE1H3iGcHy5pv6duATiCLM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250916133445.GA1875@pendragon.ideasonboard.com>","References":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>\n\t<20250916133445.GA1875@pendragon.ideasonboard.com>","Subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Date":"Tue, 16 Sep 2025 14:38:28 +0100","Message-ID":"<175802990822.1246375.4921288643544715479@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":35846,"web_url":"https://patchwork.libcamera.org/comment/35846/","msgid":"<959de6d4-9492-4543-8cd2-cd5fb818a2b4@ideasonboard.com>","date":"2025-09-16T13:43:44","subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 09. 16. 15:31 keltezéssel, Stefan Klug írta:\n> In commit b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with\n> span in constructor\") the FrameBuffer::planes() function was modified to\n> return a Span instead of a vector. This leads to the following runtime\n> exception in the python binding:\n> \n> TypeError: Unregistered type : libcamera::Span<libcamera::FrameBuffer::Plane const, 18446744073709551615ul>\n> \n> Fix that by manually converting the Span to a vector.\n> \n> Note: The best solution would be to implement a Span type caster for\n> pybind11. But implementing and testing that properly is a bit more\n> involved than expected. As we don't need bidirectional mapping, the same\n> workaround as for FrameMetadata::planes() was used for now.\n> \n> Fixes: b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with span in constructor\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>   src/py/libcamera/py_main.cpp | 8 +++++++-\n>   1 file changed, 7 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\n> index 441a70ab4d5e..70245ec78f9a 100644\n> --- a/src/py/libcamera/py_main.cpp\n> +++ b/src/py/libcamera/py_main.cpp\n> @@ -372,7 +372,13 @@ PYBIND11_MODULE(_libcamera, m)\n>   \t\t.def(py::init<std::vector<FrameBuffer::Plane>, unsigned int>(),\n>   \t\t     py::arg(\"planes\"), py::arg(\"cookie\") = 0)\n>   \t\t.def_property_readonly(\"metadata\", &FrameBuffer::metadata, py::return_value_policy::reference_internal)\n> -\t\t.def_property_readonly(\"planes\", &FrameBuffer::planes)\n> +\t\t.def_property_readonly(\"planes\", [](const FrameBuffer &self) {\n> +\t\t\t/* Convert from Span<> to std::vector<> */\n> +\t\t\t/* Note: this creates copies */\n> +\t\t\tstd::vector<FrameBuffer::Plane> v(self.planes().begin(),\n> +\t\t\t\t\t\t\t  self.planes().end());\n\nCould we make it so that `self.planes()` is called only once?\n\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\nRegards,\nBarnabás Pőcze\n\n\n> +\t\t\treturn v;\n> +\t\t})\n>   \t\t.def_property(\"cookie\", &FrameBuffer::cookie, &FrameBuffer::setCookie);\n>   \n>   \tpyFrameBufferPlane","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 6319FC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Sep 2025 13:43:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 01FBC6936F;\n\tTue, 16 Sep 2025 15:43:51 +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 214EF613A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Sep 2025 15:43:49 +0200 (CEST)","from [192.168.33.22] (185.221.142.115.nat.pool.zt.hu\n\t[185.221.142.115])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8BAF5DF3;\n\tTue, 16 Sep 2025 15:42:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"CBSOKWzL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758030150;\n\tbh=7uJV5iujE4ESxB3zB3OtQoXN/jyXL1Ote2BrOBXbo8E=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=CBSOKWzLNJ66QHTAZAiaDrBcCH8YTG7RgfM/32OWDyduMyDDF0ITBgPXIApOa3NRH\n\tARqq/Wl6MusiImVM2R3Bnb+mBNUxY4MIM7C5YIHL7wwPOzJ1WVte/62TJ9UaIiA+5y\n\tUW4Mzi0yo76kRCVeIMQGsNgynHPCPjrs/YpMZGdE=","Message-ID":"<959de6d4-9492-4543-8cd2-cd5fb818a2b4@ideasonboard.com>","Date":"Tue, 16 Sep 2025 15:43:44 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] pycamera: Fix FrameBuffer::planes wrapper","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]