{"id":24372,"url":"https://patchwork.libcamera.org/api/patches/24372/?format=json","web_url":"https://patchwork.libcamera.org/patch/24372/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","date":"2025-09-16T13:31:53","name":"pycamera: Fix FrameBuffer::planes wrapper","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b71c7808b6d11eeee1e747904422337191641c17","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24372/mbox/","series":[{"id":5446,"url":"https://patchwork.libcamera.org/api/series/5446/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5446","date":"2025-09-16T13:31:53","name":"pycamera: Fix FrameBuffer::planes wrapper","version":1,"mbox":"https://patchwork.libcamera.org/series/5446/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24372/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24372/checks/","tags":{},"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 5AE5DC328C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Sep 2025 13:32:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 50B9E69369;\n\tTue, 16 Sep 2025 15:32:41 +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 8B320613A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Sep 2025 15:32:39 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:fcf9:6932:9f30:ab03])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 43DC3DF3;\n\tTue, 16 Sep 2025 15:31:21 +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=\"pgLECg3W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1758029481;\n\tbh=Mc23btL2SvUnsTRrZ3CBM/+mAX3nwBKRpOM3lFEqD8g=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=pgLECg3WbSciueU53qSeNVLtukArzCHTy6ewwxOxfkq2MUskp0MB2saWSFT2Y0n1H\n\t7/tjD7qZnBTfhbC4tCV1KUY7XqV53lyE3DUemTbSsrrmyOWSc/W5mODAZRCVM0x7Mn\n\trtqPPM9f0rfoxSrru6htPbNvYoMSCsSW8GKBQbjs=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH] pycamera: Fix FrameBuffer::planes wrapper","Date":"Tue, 16 Sep 2025 15:31:53 +0200","Message-ID":"<20250916133234.947678-1-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","MIME-Version":"1.0","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>"},"content":"In commit b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with\nspan in constructor\") the FrameBuffer::planes() function was modified to\nreturn a Span instead of a vector. This leads to the following runtime\nexception in the python binding:\n\nTypeError: Unregistered type : libcamera::Span<libcamera::FrameBuffer::Plane const, 18446744073709551615ul>\n\nFix that by manually converting the Span to a vector.\n\nNote: The best solution would be to implement a Span type caster for\npybind11. But implementing and testing that properly is a bit more\ninvolved than expected. As we don't need bidirectional mapping, the same\nworkaround as for FrameMetadata::planes() was used for now.\n\nFixes: b8d332cdcc13 (\"libcamera: framebuffer: Replace vector with span in constructor\")\nSigned-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(-)","diff":"diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp\nindex 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\n","prefixes":[]}