[{"id":32614,"web_url":"https://patchwork.libcamera.org/comment/32614/","msgid":"<20241209015608.GA9787@pendragon.ideasonboard.com>","date":"2024-12-09T01:56:08","subject":"Re: [PATCH v5 2/8] ipa: rkisp1: awb: Load white balance gains from\n\ttuning file","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Fri, Dec 06, 2024 at 03:52:22PM +0100, Stefan Klug wrote:\n> For the implementation of a manual colour temperature setting, it is\n> necessary to read predefined colour gains per colour temperature from\n> the tuning file. Implement this in a backwards compatible way. If no\n> gains are contained in the tuning file, loading just continues as\n> before.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> ---\n> Changes in v5:\n> - Replace Interpolator<Matrix> with Interpolator<Vector>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 18 ++++++++++++++++++\n>  src/ipa/rkisp1/algorithms/awb.h   |  7 +++++++\n>  2 files changed, 25 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 4bb4f5b88375..23a81e75d3d3 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -41,6 +41,24 @@ Awb::Awb()\n>  {\n>  }\n>  \n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::init\n> + */\n> +int Awb::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n> +{\n> +\tInterpolator<Vector<double, 2>> gains;\n> +\tint ret = gains.readYaml(tuningData[\"gains\"], \"ct\", \"gains\");\n> +\tif (ret < 0)\n> +\t\tLOG(RkISP1Awb, Warning)\n> +\t\t\t<< \"Failed to parse 'gains' \"\n> +\t\t\t<< \"parameter from tuning file; \"\n> +\t\t\t<< \"manual colour temperature will not work properly\";\n> +\telse\n> +\t\tgains_ = gains;\n\nI got a bit confused by gains_ when reviewing 3/8 as I had forgotten\nabout this change. I'm wondering if the code (and tuning data) would be\nclearer if we used CT curve (\"ct-curve\", ctCurve_) instead of gains.\n\n> +\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::configure\n>   */\n> diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h\n> index 6ac3a5c3838b..a7e0537c66d9 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.h\n> +++ b/src/ipa/rkisp1/algorithms/awb.h\n> @@ -7,6 +7,11 @@\n>  \n>  #pragma once\n>  \n> +#include <optional>\n> +\n> +#include \"libipa/interpolator.h\"\n> +#include \"libipa/vector.h\"\n> +\n>  #include \"algorithm.h\"\n>  \n>  namespace libcamera {\n> @@ -19,6 +24,7 @@ public:\n>  \tAwb();\n>  \t~Awb() = default;\n>  \n> +\tint init(IPAContext &context, const YamlObject &tuningData) override;\n>  \tint configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;\n>  \tvoid queueRequest(IPAContext &context, const uint32_t frame,\n>  \t\t\t  IPAFrameContext &frameContext,\n> @@ -32,6 +38,7 @@ public:\n>  \t\t     ControlList &metadata) override;\n>  \n>  private:\n> +\tstd::optional<Interpolator<Vector<double, 2>>> gains_;\n>  \tbool rgbMode_;\n>  };\n>","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 9E6ABC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  9 Dec 2024 01:56:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9F1BE67E41;\n\tMon,  9 Dec 2024 02:56:25 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35967660E7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  9 Dec 2024 02:56:24 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B0F13496;\n\tMon,  9 Dec 2024 02:55:52 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"X1TxqLqp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733709352;\n\tbh=tSxIKoRPI90eZ4iTbnC0Yg0VjYz5l3Ygy8ojv5wQe0E=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=X1TxqLqpflyEVs/9lBFiTKJo2dzyfJQdaYQDLM2CZC1NiWcsLQDz+Zq054qr85rD4\n\tH6r5XE7WKQqJ5ypVh222ipyhj0K0xi27nVvxB1dAy8Ljb91D7+3Br1bqmCCh5cp3KZ\n\tOpSnI+xy9YE5xlweQb9+ZorxPFnVxMydMeZFl260=","Date":"Mon, 9 Dec 2024 03:56:08 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>","Subject":"Re: [PATCH v5 2/8] ipa: rkisp1: awb: Load white balance gains from\n\ttuning file","Message-ID":"<20241209015608.GA9787@pendragon.ideasonboard.com>","References":"<20241206145242.827886-1-stefan.klug@ideasonboard.com>\n\t<20241206145242.827886-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241206145242.827886-3-stefan.klug@ideasonboard.com>","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>"}}]