From patchwork Mon Apr 19 13:14:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11994 X-Patchwork-Delegate: jacopo@jmondi.org 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 0808EBD814 for ; Mon, 19 Apr 2021 13:14:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B13246883F; Mon, 19 Apr 2021 15:14:31 +0200 (CEST) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8250468842 for ; Mon, 19 Apr 2021 15:14:24 +0200 (CEST) Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 20141100005; Mon, 19 Apr 2021 13:14:23 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 19 Apr 2021 15:14:32 +0200 Message-Id: <20210419131433.22920-13-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419131433.22920-1-jacopo@jmondi.org> References: <20210419131433.22920-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/13] cam: Implement OptMetadata 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" Implement support for the new '--metadata' option by printing the value of each metadata entry associated with a completed Request. As sample of the output, running on raspberry pi, looks like the following: 3050.205672 (30.01 fps) stream0 seq: 000033 bytesused: 720000 ScalerCrop = (0x2)/3280x2460 ExposureTime = 13969 AeLocked = true DigitalGain = 1.000721 Lux = 771.204224 ColourGains = [ 1.561101, 1.629698 ] ColourTemperature = 4289 SensorBlackLevels = [ 4096, 4096, 4096, 4096 ] ColourCorrectionMatrix = [ 1.691066, -0.599756, -0.091317, -0.437452, 1.983766, -0.546314, -0.083429, -0.722407, 1.805836 ] AnalogueGain = 2.000000 SensorTimestamp = 3050205672000 3050.238999 (30.01 fps) stream0 seq: 000034 bytesused: 720000 ScalerCrop = (0x2)/3280x2460 ExposureTime = 13969 AeLocked = true DigitalGain = 1.000709 Lux = 771.232422 ColourGains = [ 1.560868, 1.630029 ] ColourTemperature = 4289 SensorBlackLevels = [ 4096, 4096, 4096, 4096 ] ColourCorrectionMatrix = [ 1.691081, -0.599726, -0.091362, -0.437497, 1.983627, -0.546130, -0.083420, -0.722523, 1.805943 ] AnalogueGain = 2.000000 SensorTimestamp = 3050238999000 Signed-off-by: Jacopo Mondi --- src/cam/capture.cpp | 15 ++++++++++++++- src/cam/capture.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp index 7b55fc677022..7213abd934ec 100644 --- a/src/cam/capture.cpp +++ b/src/cam/capture.cpp @@ -10,6 +10,8 @@ #include #include +#include + #include "capture.h" #include "main.h" @@ -18,7 +20,8 @@ using namespace libcamera; Capture::Capture(std::shared_ptr camera, CameraConfiguration *config, EventLoop *loop) : camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop), - queueCount_(0), captureCount_(0), captureLimit_(0) + queueCount_(0), captureCount_(0), captureLimit_(0), + printMetadata_(false) { } @@ -29,6 +32,7 @@ int Capture::run(const OptionsParser::Options &options) queueCount_ = 0; captureCount_ = 0; captureLimit_ = options[OptCapture].toInteger(); + printMetadata_ = options.isSet(OptMetadata); if (!camera_) { std::cout << "Can't capture without a camera" << std::endl; @@ -217,6 +221,15 @@ void Capture::processRequest(Request *request) std::cout << info.str() << std::endl; + if (printMetadata_) { + const ControlList &requestMetadata = request->metadata(); + for (const auto ctrl : requestMetadata) { + const ControlId *id = controls::controls.at(ctrl.first); + std::cout << "\t" << id->name() << " = " + << ctrl.second.toString() << std::endl; + } + } + captureCount_++; if (captureLimit_ && captureCount_ >= captureLimit_) { loop_->exit(0); diff --git a/src/cam/capture.h b/src/cam/capture.h index c7c9dc00d30f..59d138766b1e 100644 --- a/src/cam/capture.h +++ b/src/cam/capture.h @@ -47,6 +47,7 @@ private: unsigned int queueCount_; unsigned int captureCount_; unsigned int captureLimit_; + bool printMetadata_; std::vector> requests_; };