[{"id":33381,"web_url":"https://patchwork.libcamera.org/comment/33381/","msgid":"<173979519654.1238111.5637287225670939150@ping.linuxembedded.co.uk>","date":"2025-02-17T12:26:36","subject":"Re: [PATCH 09/10] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-02-17 10:01:50)\n> Apparently AWB measurements are taken after the CCM. So the estimated\n\nAre we more sure than 'apparantly' ? What do we need to do to be more\nconfident or certain of this ?\n\n> colour temperature and the corresponding CCM also lead to changed\n> rgbMeans. This is another source of oscillations. Fix that by applying\n> the inverse transform on the rgbMeans.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 2 ++\n>  1 file changed, 2 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 12934771c69c..66e6aecedc4c 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -305,6 +305,8 @@ void Awb::process(IPAContext &context,\n>                 rgbMeans = rgbMeans.max(0.0);\n>         }\n>  \n\nI would definitely put a block comment here describing /why/ we are\ndoing this - likely matching closely to what you have in the commit\nmessage.\n\n> +       rgbMeans = frameContext.ccm.ccm.cast<double>().inverse() * rgbMeans;\n> +\n>         /*\n>          * The ISP computes the AWB means after applying the colour gains,\n>          * divide by the gains that were used to get the raw means from the\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 3208BBE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 12:26:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 595F76866F;\n\tMon, 17 Feb 2025 13:26:41 +0100 (CET)","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 996E361865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 13:26:39 +0100 (CET)","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 1AE19842;\n\tMon, 17 Feb 2025 13:25:18 +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=\"kTO4Qoa8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739795118;\n\tbh=RFlNo0Lx15GAufvrKvbh2rFJWVLTu4h3ZJfgq9Eb6cI=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=kTO4Qoa8bGhyW3Ew9+LX4nbb4hxh/XnlkLT1Iixabydg1N07deKEtJp7CZ+tjYRq7\n\t4ZQv9838ZERel7RUtgqHeeaKZjRvvo81XKJLaU0glKCI8aXAyI00Epj7qT4IT1uj45\n\tzAp8JRw0dD8zcDDtHyr9DCcDO+jwujnR1bAJQHk0=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250217100203.297894-10-stefan.klug@ideasonboard.com>","References":"<20250217100203.297894-1-stefan.klug@ideasonboard.com>\n\t<20250217100203.297894-10-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH 09/10] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","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, 17 Feb 2025 12:26:36 +0000","Message-ID":"<173979519654.1238111.5637287225670939150@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":33387,"web_url":"https://patchwork.libcamera.org/comment/33387/","msgid":"<g4ae34pfdwszrnp5wiwt5zknk5tgbo2ktkn63r2fmwh3a3mww5@ojdojsrdyqqf>","date":"2025-02-17T15:16:17","subject":"Re: [PATCH 09/10] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the review. \n\nOn Mon, Feb 17, 2025 at 12:26:36PM +0000, Kieran Bingham wrote:\n> Quoting Stefan Klug (2025-02-17 10:01:50)\n> > Apparently AWB measurements are taken after the CCM. So the estimated\n> \n> Are we more sure than 'apparantly' ? What do we need to do to be more\n> confident or certain of this ?\n\nYou are right. I will explain how to test that in v2. Basically, you can\ncomment the gains from the manual colour temperture code path and enable\nAWB debug logs. Then you can see the measurements change, when you\nmodify the colour temperature. (I just realize that we can't manually\nset the CCM on rkisp1. That would have been an even easier test)\n\n> \n> > colour temperature and the corresponding CCM also lead to changed\n> > rgbMeans. This is another source of oscillations. Fix that by applying\n> > the inverse transform on the rgbMeans.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> >  src/ipa/rkisp1/algorithms/awb.cpp | 2 ++\n> >  1 file changed, 2 insertions(+)\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> > index 12934771c69c..66e6aecedc4c 100644\n> > --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> > +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> > @@ -305,6 +305,8 @@ void Awb::process(IPAContext &context,\n> >                 rgbMeans = rgbMeans.max(0.0);\n> >         }\n> >  \n> \n> I would definitely put a block comment here describing /why/ we are\n> doing this - likely matching closely to what you have in the commit\n> message.\n\nRight. Will add one.\n\nBest regards,\nStefan\n\n> \n> > +       rgbMeans = frameContext.ccm.ccm.cast<double>().inverse() * rgbMeans;\n> > +\n> >         /*\n> >          * The ISP computes the AWB means after applying the colour gains,\n> >          * divide by the gains that were used to get the raw means from the\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 4D310BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 15:16:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 65CA768674;\n\tMon, 17 Feb 2025 16:16:23 +0100 (CET)","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 02B3D6866C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 16:16:20 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b47f:e20a:c4c7:ece1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 73E4D22F;\n\tMon, 17 Feb 2025 16:14:59 +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=\"EYTExqhm\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739805299;\n\tbh=bm1yrsh7CE67UJJmiAeo0jIYXNgNWECz4qXwsHgqr+M=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=EYTExqhma9ofSxsJVESgIu+O3Ui90gMs/g2Oh2aqi/dgJaVTfqZ13ewVctUqC9FJG\n\tftO0wzYxpw65y3Ix7DiwZGC+draTkYEL/Qt4Km2jeOBdfbr40+g4RxfNWaDEjXd/tb\n\tezifD8PaAReTIbO7CAAHW6SH3YRssKSBMg3VceKc=","Date":"Mon, 17 Feb 2025 16:16:17 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 09/10] ipa: rkisp1: awb: Take the CCM into account for\n\tthe AWB gains calculation","Message-ID":"<g4ae34pfdwszrnp5wiwt5zknk5tgbo2ktkn63r2fmwh3a3mww5@ojdojsrdyqqf>","References":"<20250217100203.297894-1-stefan.klug@ideasonboard.com>\n\t<20250217100203.297894-10-stefan.klug@ideasonboard.com>\n\t<173979519654.1238111.5637287225670939150@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<173979519654.1238111.5637287225670939150@ping.linuxembedded.co.uk>","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>"}}]