[{"id":33800,"web_url":"https://patchwork.libcamera.org/comment/33800/","msgid":"<174344316593.3394313.12492289186475329681@ping.linuxembedded.co.uk>","date":"2025-03-31T17:46:05","subject":"Re: [PATCH v2 13/17] ipa: rkisp1: awb: Use gains from color\n\ttemperature curve","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-03-19 16:11:18)\n> Use the color gains for white balance if calibrated light sources are\n> contained in the tuning file. The results are generally better\n> especially when large uniformly colored objects are in the scene. Pure\n> grey world model is still available by removing the color gains from the\n> tuning file.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 58b8370d2c61..286d9e3e2018 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -218,6 +218,16 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>                 auto &awb = context.activeState.awb;\n>                 frameContext.awb.gains = awb.automatic.gains;\n>                 frameContext.awb.temperatureK = awb.automatic.temperatureK;\n> +\n> +               const auto &gains = awbAlgo_->gainsFromColourTemperature(\n> +                       awb.automatic.temperatureK);\n> +               if (gains) {\n> +                       frameContext.awb.gains.r() = gains->r();\n> +                       frameContext.awb.gains.g() = 1.0;\n> +                       frameContext.awb.gains.b() = gains->b();\n> +               } else {\n> +                       frameContext.awb.gains = awb.automatic.gains;\n> +               }\n>         }\n>  \n>         auto gainConfig = params->block<BlockType::AwbGain>();\n> -- \n> 2.43.0\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 2A857C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 31 Mar 2025 17:46:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D5CB668986;\n\tMon, 31 Mar 2025 19:46:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF66368967\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 31 Mar 2025 19:46:08 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 56832703;\n\tMon, 31 Mar 2025 19:44:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QwJ5tAeD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743443057;\n\tbh=RqskXD8yQQVetqsczX72zEb9KUaBMCfaURkkDQOEGTM=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QwJ5tAeDZwayKc2r/cVqDj8jSUbnHknjM908BC6/mFiEwW1PV+EX06m+XhskhGaXv\n\tx/NWYUEK4O1qqzvHbbglFDE/orMwS0wQ2Q5wYSt8g1EJTyaDjd03CfmiDJXLXjGEx9\n\t3v/zgHI5gI6HkLFWJ6QKSUq07ug0AR4XgKR6fD0c=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250319161152.63625-14-stefan.klug@ideasonboard.com>","References":"<20250319161152.63625-1-stefan.klug@ideasonboard.com>\n\t<20250319161152.63625-14-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v2 13/17] ipa: rkisp1: awb: Use gains from color\n\ttemperature curve","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 31 Mar 2025 18:46:05 +0100","Message-ID":"<174344316593.3394313.12492289186475329681@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":33835,"web_url":"https://patchwork.libcamera.org/comment/33835/","msgid":"<20250401020258.GA26315@pendragon.ideasonboard.com>","date":"2025-04-01T02:02:58","subject":"Re: [PATCH v2 13/17] ipa: rkisp1: awb: Use gains from color\n\ttemperature curve","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Wed, Mar 19, 2025 at 05:11:18PM +0100, Stefan Klug wrote:\n> Use the color gains for white balance if calibrated light sources are\n> contained in the tuning file. The results are generally better\n> especially when large uniformly colored objects are in the scene. Pure\n> grey world model is still available by removing the color gains from the\n> tuning file.\n\nWe'll get an error in the log for every frame then. I think that needs\nto be addressed.\n\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 58b8370d2c61..286d9e3e2018 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -218,6 +218,16 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>  \t\tauto &awb = context.activeState.awb;\n>  \t\tframeContext.awb.gains = awb.automatic.gains;\n\nThis doesn't seem to be needed anymore.\n\n>  \t\tframeContext.awb.temperatureK = awb.automatic.temperatureK;\n> +\n> +\t\tconst auto &gains = awbAlgo_->gainsFromColourTemperature(\n> +\t\t\tawb.automatic.temperatureK);\n> +\t\tif (gains) {\n> +\t\t\tframeContext.awb.gains.r() = gains->r();\n> +\t\t\tframeContext.awb.gains.g() = 1.0;\n> +\t\t\tframeContext.awb.gains.b() = gains->b();\n> +\t\t} else {\n> +\t\t\tframeContext.awb.gains = awb.automatic.gains;\n> +\t\t}\n\nShouldn't this be done in Awb::process() where awb.automatic.gains is\nset ? Or maybe even in calculateAwb() ?\n\n>  \t}\n>  \n>  \tauto gainConfig = params->block<BlockType::AwbGain>();","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 62F75C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Apr 2025 02:03:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7477C68981;\n\tTue,  1 Apr 2025 04:03:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 685A162C66\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Apr 2025 04:03:23 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-147-224-nat.elisa-mobile.fi\n\t[85.76.147.224])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 276BE250;\n\tTue,  1 Apr 2025 04:01:31 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QXqyFsk5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743472891;\n\tbh=fEX3LeiFHK4PqrlFd2IhSGHf6vC2GqAHAl5TucttIm0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QXqyFsk563swLE4x6dLYpGr/grQjhnr6ZEMHD+E13Z8Ho/DzQciqrStKqFwpiV1Du\n\t5rlNxXIEeBsGpwPN/6eAoKSe/8GFNocPcAUB4WAwC80Tju/Hjfk+X+c7rk60YtzWI0\n\t+JaVWnRN1TS0cdLMBTVYki4iJ+NW2+lEDI/XU0js=","Date":"Tue, 1 Apr 2025 05:02:58 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 13/17] ipa: rkisp1: awb: Use gains from color\n\ttemperature curve","Message-ID":"<20250401020258.GA26315@pendragon.ideasonboard.com>","References":"<20250319161152.63625-1-stefan.klug@ideasonboard.com>\n\t<20250319161152.63625-14-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250319161152.63625-14-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>"}}]