From patchwork Fri May 27 14:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16095 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 62E0BC3270 for ; Fri, 27 May 2022 14:45:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05644656A4; Fri, 27 May 2022 16:45:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653662737; bh=jsTL+qIbxJSn7ZLPLtfga4ld9MZGQRdgxhEB4elyv3o=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=iq6KTxvDzcGAV5SCNRkuzrVoNwFhM65ziulbuasr6fw4l+GT9s+McmmZVH1hcznmY L1M6QSm5s/9eovyWtPiTadjIfWcw3WrqBN7x6AS6wbdk1E+Cxf4DsQ4eFeRROvS+F7 wLMU9ktogumnDV1i1Ix43BPYE3e/sUvpHhOnFYOHz4Y/9fnvenuwrEDdJEoFir0EZB IBkijo/vFMtGgiPwOvHHm90mVyQBGtEb7d0APc8NBLk0E2n54/jeZk44lqRArk4IkH fS++lmgR1+gtYjPrB9kF9/2gR+RW10hVelswMwDBod/6YVT7wUA+PuDmni1NaSPhlE jdelWNsKMx03w== 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 DD3BD6563F for ; Fri, 27 May 2022 16:45:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KevzTX83"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 53B9FD80; Fri, 27 May 2022 16:45:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653662715; bh=jsTL+qIbxJSn7ZLPLtfga4ld9MZGQRdgxhEB4elyv3o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KevzTX83ebK2wqEdOUpFCDKUxx2zjW6fTpaZk6pcM5J8Lj0xdNwApXfvVTjb6B+o3 d8TxlLclD3Td0QrrrHRChvMNmDTSCs1VhNvdfx5q78Yns5Br9YkMyvoSKQ7HlO0eSX 6328V9tVMXZh2hIW7hLll7cDddPlVGkmDmhQhWw8= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Fri, 27 May 2022 17:44:39 +0300 Message-Id: <20220527144447.94891-23-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220527144447.94891-1-tomi.valkeinen@ideasonboard.com> References: <20220527144447.94891-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 22/30] py: Add FrameMetadataPlane 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: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add FrameMetadataPlane class and adjust the methods and uses accordingly. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- src/py/cam/cam.py | 3 ++- src/py/libcamera/py_main.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/py/cam/cam.py b/src/py/cam/cam.py index 677dd680..bf8529d9 100755 --- a/src/py/cam/cam.py +++ b/src/py/cam/cam.py @@ -285,7 +285,8 @@ class CaptureState: print('{:.6f} ({:.2f} fps) {}-{}: seq {}, bytes {}, CRCs {}' .format(ts / 1000000000, fps, ctx.id, stream_name, - meta.sequence, meta.bytesused, + meta.sequence, + '/'.join([str(p.bytes_used) for p in meta.planes]), crcs)) if ctx.opt_metadata: diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp index 9e827845..52f70811 100644 --- a/src/py/libcamera/py_main.cpp +++ b/src/py/libcamera/py_main.cpp @@ -163,6 +163,7 @@ PYBIND11_MODULE(_libcamera, m) auto pyRequestReuse = py::enum_(pyRequest, "Reuse"); auto pyFrameMetadata = py::class_(m, "FrameMetadata"); auto pyFrameMetadataStatus = py::enum_(pyFrameMetadata, "Status"); + auto pyFrameMetadataPlane = py::class_(pyFrameMetadata, "Plane"); auto pyTransform = py::class_(m, "Transform"); auto pyColorSpace = py::class_(m, "ColorSpace"); auto pyColorSpacePrimaries = py::enum_(pyColorSpace, "Primaries"); @@ -512,11 +513,10 @@ PYBIND11_MODULE(_libcamera, m) .def_readonly("status", &FrameMetadata::status) .def_readonly("sequence", &FrameMetadata::sequence) .def_readonly("timestamp", &FrameMetadata::timestamp) - /* \todo Implement FrameMetadata::Plane properly */ - .def_property_readonly("bytesused", [](FrameMetadata &self) { - std::vector v; - v.resize(self.planes().size()); - transform(self.planes().begin(), self.planes().end(), v.begin(), [](const auto &p) { return p.bytesused; }); + .def_property_readonly("planes", [](const FrameMetadata &self) { + /* Convert from Span<> to std::vector<> */ + /* Note: this creates a copy */ + std::vector v(self.planes().begin(), self.planes().end()); return v; }); @@ -525,6 +525,9 @@ PYBIND11_MODULE(_libcamera, m) .value("Error", FrameMetadata::FrameError) .value("Cancelled", FrameMetadata::FrameCancelled); + pyFrameMetadataPlane + .def_readwrite("bytes_used", &FrameMetadata::Plane::bytesused); + pyTransform .def(py::init([](int rotation, bool hflip, bool vflip, bool transpose) { bool ok;