From patchwork Fri Apr 11 13:04:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23175 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 72C6BC3213 for ; Fri, 11 Apr 2025 13:04:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2AADC68AB4; Fri, 11 Apr 2025 15:04:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Rfz8rFf/"; 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 A9BFA68AB4 for ; Fri, 11 Apr 2025 15:04:49 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:5b21:2ad5:1023:7179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5E01E735; Fri, 11 Apr 2025 15:02:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1744376570; bh=a4GTBrVlT555xzFzrZUEcNd7nTZIbDjvjOE1SuHrkiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rfz8rFf/ZHpVpZfVL4B5H8zIL5SCEVixRKD0xbRPt64yeBde6lPmpjNFuyj+okAhX iaBRWxdysODrLNU0IRDCPav5oje5Om0yrMuIO9il8fxLY47MVPzmzP9aE/qmrebvSV o5LsOVzvIOEJq4RVhDpSbQGCDvhOD73eIxcZTNlg= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH 8/8] ipa: rkisp1: agc: Add debug controls for statistic values Date: Fri, 11 Apr 2025 15:04:15 +0200 Message-ID: <20250411130423.2164577-9-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250411130423.2164577-1-stefan.klug@ideasonboard.com> References: <20250411130423.2164577-1-stefan.klug@ideasonboard.com> 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" Add debug controls for AWB stats and exposure means. Signed-off-by: Stefan Klug --- src/ipa/rkisp1/algorithms/agc.cpp | 16 +++++++++++++++ src/ipa/rkisp1/algorithms/awb.cpp | 3 +++ src/libcamera/control_ids_debug.yaml | 29 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index a2c8d5403ba2..6dc8b9fc0a31 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -400,8 +400,10 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext, { utils::Duration exposureTime = context.configuration.sensor.lineDuration * frameContext.sensor.exposure; + utils::Duration exposureTimeCorrected = exposureTime * frameContext.awb.additionalGain; metadata.set(controls::AnalogueGain, frameContext.sensor.gain); metadata.set(controls::ExposureTime, exposureTime.get()); + metadata.set(controls::debug::ExposureTimeCorrected, exposureTimeCorrected.get()); metadata.set(controls::FrameDuration, frameContext.agc.frameDuration.get()); metadata.set(controls::ExposureTimeMode, frameContext.agc.autoExposureEnabled @@ -574,6 +576,20 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, frameContext.agc.exposureMode, hist, effectiveExposureValue); + auto &debugMeta = context.debugMetadata; + std::vector histMeta; + for (unsigned i = 0; i < context.hw->numHistogramBins; i++) + histMeta.push_back(params->hist.hist_bins[i] >> 4); + debugMeta.set>(controls::debug::StatsHistogram, histMeta); + + double meanExposure = 0; + for (uint8_t expMean : expMeans_) + meanExposure += expMean; + meanExposure = meanExposure / expMeans_.size() / 255.0; + debugMeta.set(controls::debug::StatsExpMean, meanExposure); + + debugMeta.set>(controls::debug::StatsExpMeans, expMeans_); + LOG(RkISP1Agc, Debug) << "Divided up exposure time, analogue gain and digital gain are " << newExposureTime << ", " << aGain << " and " << dGain; diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index cc78136a22c8..be08458e45e3 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -310,6 +310,9 @@ void Awb::process(IPAContext &context, RGB rgbMeans = calculateRgbMeans(frameContext, awb); + context.debugMetadata.set>(controls::debug::RgbMeans, Vector(rgbMeans).data()); + context.debugMetadata.set(controls::debug::AwbCount, awb->awb_mean[0].cnt); + /* * If the means are too small we don't have enough information to * meaningfully calculate gains. Freeze the algorithm in that case. diff --git a/src/libcamera/control_ids_debug.yaml b/src/libcamera/control_ids_debug.yaml index 9489e677402e..d0f9329187f7 100644 --- a/src/libcamera/control_ids_debug.yaml +++ b/src/libcamera/control_ids_debug.yaml @@ -1,9 +1,38 @@ # SPDX-License-Identifier: LGPL-2.1-or-later # +# This file was generated by utils/gen-debug-controls.py +# %YAML 1.1 --- vendor: debug controls: +- AwbCount: + type: int + direction: out + description: Debug control AwbCount found in src/ipa/rkisp1/algorithms/awb.cpp +- ExposureTimeCorrected: + type: float + direction: out + description: Debug control ExposureTimeCorrected found in src/ipa/rkisp1/algorithms/agc.cpp +- RgbMeans: + type: float + direction: out + description: Debug control RgbMeans found in src/ipa/rkisp1/algorithms/awb.cpp + size: '[n]' +- StatsExpMean: + type: const float + direction: out + description: Debug control StatsExpMean found in src/ipa/rkisp1/algorithms/agc.cpp +- StatsExpMeans: + type: uint8_t + direction: out + description: Debug control StatsExpMeans found in src/ipa/rkisp1/algorithms/agc.cpp + size: '[n]' +- StatsHistogram: + type: int32_t + direction: out + description: Debug control StatsHistogram found in src/ipa/rkisp1/algorithms/agc.cpp + size: '[n]' - WdrCurve: type: Point direction: out