From patchwork Tue Sep 16 13:31:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24372 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 5AE5DC328C for ; Tue, 16 Sep 2025 13:32:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50B9E69369; Tue, 16 Sep 2025 15:32:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pgLECg3W"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B320613A1 for ; Tue, 16 Sep 2025 15:32:39 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:fcf9:6932:9f30:ab03]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 43DC3DF3; Tue, 16 Sep 2025 15:31:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1758029481; bh=Mc23btL2SvUnsTRrZ3CBM/+mAX3nwBKRpOM3lFEqD8g=; h=From:To:Cc:Subject:Date:From; b=pgLECg3WbSciueU53qSeNVLtukArzCHTy6ewwxOxfkq2MUskp0MB2saWSFT2Y0n1H 7/tjD7qZnBTfhbC4tCV1KUY7XqV53lyE3DUemTbSsrrmyOWSc/W5mODAZRCVM0x7Mn rtqPPM9f0rfoxSrru6htPbNvYoMSCsSW8GKBQbjs= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug 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 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In commit b8d332cdcc13 ("libcamera: framebuffer: Replace vector with span in constructor") the FrameBuffer::planes() function was modified to return a Span instead of a vector. This leads to the following runtime exception in the python binding: TypeError: Unregistered type : libcamera::Span Fix that by manually converting the Span to a vector. Note: The best solution would be to implement a Span type caster for pybind11. But implementing and testing that properly is a bit more involved than expected. As we don't need bidirectional mapping, the same workaround as for FrameMetadata::planes() was used for now. Fixes: b8d332cdcc13 ("libcamera: framebuffer: Replace vector with span in constructor") Signed-off-by: Stefan Klug Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Barnabás Pőcze --- src/py/libcamera/py_main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 441a70ab4d5e..70245ec78f9a 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -372,7 +372,13 @@ PYBIND11_MODULE(_libcamera, m) .def(py::init, unsigned int>(), py::arg("planes"), py::arg("cookie") = 0) .def_property_readonly("metadata", &FrameBuffer::metadata, py::return_value_policy::reference_internal) - .def_property_readonly("planes", &FrameBuffer::planes) + .def_property_readonly("planes", [](const FrameBuffer &self) { + /* Convert from Span<> to std::vector<> */ + /* Note: this creates copies */ + std::vector v(self.planes().begin(), + self.planes().end()); + return v; + }) .def_property("cookie", &FrameBuffer::cookie, &FrameBuffer::setCookie); pyFrameBufferPlane