[{"id":30571,"web_url":"https://patchwork.libcamera.org/comment/30571/","msgid":"<172284327723.2725865.1878748919561692023@ping.linuxembedded.co.uk>","date":"2024-08-05T07:34:37","subject":"Re: [PATCH v1 1/2] utils: tuning: rkisp1: Clean up tuner\n\tconstruction","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-08-05 08:06:32)\n> The instances of the static modules need to be passed to\n> tuner.set_output_order() instead of the class.  This is the reason for\n> the intermediate variables. To keep the code tidy, apply the same\n> pattern to the other modules.\n> \n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  utils/tuning/rkisp1.py | 47 +++++++++++++++++++++---------------------\n>  1 file changed, 24 insertions(+), 23 deletions(-)\n> \n> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py\n> index 0d279a39ab1b..5d7a69fc4a13 100755\n> --- a/utils/tuning/rkisp1.py\n> +++ b/utils/tuning/rkisp1.py\n> @@ -19,44 +19,45 @@ from libtuning.modules.static import StaticModule\n>  \n>  coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s')\n>  \n> +agc = AGCRkISP1(debug=[lt.Debug.Plot])\n>  awb = StaticModule('Awb')\n>  blc = StaticModule('BlackLevelCorrection')\n> +ccm = CCMRkISP1(debug=[lt.Debug.Plot])\n>  color_processing = StaticModule('ColorProcessing')\n>  filter = StaticModule('Filter')\n>  gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})\n> +lsc = LSCRkISP1(debug=[lt.Debug.Plot],\n> +                # This is for the actual LSC tuning, and is part of the base LSC\n> +                # module. rkisp1's table sector sizes (16x16 programmed as mirrored\n> +                # 8x8) are separate, and is hardcoded in its specific LSC tuning\n> +                # module.\n> +                sector_shape=(17, 17),\n> +\n> +                sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> +                sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> +\n> +                # This is the function that will be used to average the pixels in\n> +                # each sector. This can also be a custom function.\n> +                sector_average_function=lt.average.Mean(),\n> +\n> +                # This is the function that will be used to smooth the color ratio\n> +                # values.  This can also be a custom function.\n> +                smoothing_function=lt.smoothing.MedianBlur(3),)\n>  \n>  tuner = lt.Tuner('RkISP1')\n> -tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))\n> +tuner.add(agc)\n>  tuner.add(awb)\n>  tuner.add(blc)\n> -tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))\n> +tuner.add(ccm)\n>  tuner.add(color_processing)\n>  tuner.add(filter)\n>  tuner.add(gamma_out)\n> -tuner.add(LSCRkISP1(\n> -          debug=[lt.Debug.Plot],\n> -          # This is for the actual LSC tuning, and is part of the base LSC\n> -          # module. rkisp1's table sector sizes (16x16 programmed as mirrored\n> -          # 8x8) are separate, and is hardcoded in its specific LSC tuning\n> -          # module.\n> -          sector_shape=(17, 17),\n> -\n> -          sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> -          sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> -\n> -          # This is the function that will be used to average the pixels in\n> -          # each sector. This can also be a custom function.\n> -          sector_average_function=lt.average.Mean(),\n> -\n> -          # This is the function that will be used to smooth the color ratio\n> -          # values.  This can also be a custom function.\n> -          smoothing_function=lt.smoothing.MedianBlur(3),\n> -          ))\n> +tuner.add(lsc)\n>  \n>  tuner.set_input_parser(YamlParser())\n>  tuner.set_output_formatter(YamlOutput())\n> -tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing,\n> -                        filter, gamma_out, LSCRkISP1])\n> +tuner.set_output_order([agc, awb, blc, ccm, color_processing,\n> +                        filter, gamma_out, lsc])\n>  \n>  if __name__ == '__main__':\n>      sys.exit(tuner.run(sys.argv))\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 2249BBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Aug 2024 07:34:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 317BF63383;\n\tMon,  5 Aug 2024 09:34:41 +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 F34E66195A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Aug 2024 09:34:39 +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 9BF901A2;\n\tMon,  5 Aug 2024 09:33:48 +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=\"Y+8gCI34\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1722843228;\n\tbh=PWaqMv+ZrIA5VidbHFox8CluZqWedrE5V3Asq3e04ac=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Y+8gCI34NKs1foQsi9Zh1j4cV7DMitdNbja/4X9J8oEsezeiG6Z5vMUCS5BJYh4l+\n\tDvsdeGMf2LMCzDqTrJPMbup4ViToHuvmo/WfY98yKQttAu+rFoXZze9pg8WgHym3ax\n\tpA2h6/vCB+romvVygpqZqacY9ZWKUzqQBpEe2zMY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240805070644.1536232-2-stefan.klug@ideasonboard.com>","References":"<20240805070644.1536232-1-stefan.klug@ideasonboard.com>\n\t<20240805070644.1536232-2-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 1/2] utils: tuning: rkisp1: Clean up tuner\n\tconstruction","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, 05 Aug 2024 08:34:37 +0100","Message-ID":"<172284327723.2725865.1878748919561692023@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":30804,"web_url":"https://patchwork.libcamera.org/comment/30804/","msgid":"<Zrxiw6gM3tfO70dg@pyrite.rasen.tech>","date":"2024-08-14T07:54:43","subject":"Re: [PATCH v1 1/2] utils: tuning: rkisp1: Clean up tuner\n\tconstruction","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Mon, Aug 05, 2024 at 09:06:32AM +0200, Stefan Klug wrote:\n> The instances of the static modules need to be passed to\n\nStrictly speaking the matching is done via the class variable 'type', so\nyou only need the pass the class. StaticModule is special in that the\nclass variable 'type' is dependent on the instance...\n\n> tuner.set_output_order() instead of the class.  This is the reason for\n> the intermediate variables. To keep the code tidy, apply the same\n> pattern to the other modules.\n\nBut still this makes it cleaner so\n\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  utils/tuning/rkisp1.py | 47 +++++++++++++++++++++---------------------\n>  1 file changed, 24 insertions(+), 23 deletions(-)\n> \n> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py\n> index 0d279a39ab1b..5d7a69fc4a13 100755\n> --- a/utils/tuning/rkisp1.py\n> +++ b/utils/tuning/rkisp1.py\n> @@ -19,44 +19,45 @@ from libtuning.modules.static import StaticModule\n>  \n>  coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s')\n>  \n> +agc = AGCRkISP1(debug=[lt.Debug.Plot])\n>  awb = StaticModule('Awb')\n>  blc = StaticModule('BlackLevelCorrection')\n> +ccm = CCMRkISP1(debug=[lt.Debug.Plot])\n>  color_processing = StaticModule('ColorProcessing')\n>  filter = StaticModule('Filter')\n>  gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})\n> +lsc = LSCRkISP1(debug=[lt.Debug.Plot],\n> +                # This is for the actual LSC tuning, and is part of the base LSC\n> +                # module. rkisp1's table sector sizes (16x16 programmed as mirrored\n> +                # 8x8) are separate, and is hardcoded in its specific LSC tuning\n> +                # module.\n> +                sector_shape=(17, 17),\n> +\n> +                sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> +                sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> +\n> +                # This is the function that will be used to average the pixels in\n> +                # each sector. This can also be a custom function.\n> +                sector_average_function=lt.average.Mean(),\n> +\n> +                # This is the function that will be used to smooth the color ratio\n> +                # values.  This can also be a custom function.\n> +                smoothing_function=lt.smoothing.MedianBlur(3),)\n>  \n>  tuner = lt.Tuner('RkISP1')\n> -tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))\n> +tuner.add(agc)\n>  tuner.add(awb)\n>  tuner.add(blc)\n> -tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))\n> +tuner.add(ccm)\n>  tuner.add(color_processing)\n>  tuner.add(filter)\n>  tuner.add(gamma_out)\n> -tuner.add(LSCRkISP1(\n> -          debug=[lt.Debug.Plot],\n> -          # This is for the actual LSC tuning, and is part of the base LSC\n> -          # module. rkisp1's table sector sizes (16x16 programmed as mirrored\n> -          # 8x8) are separate, and is hardcoded in its specific LSC tuning\n> -          # module.\n> -          sector_shape=(17, 17),\n> -\n> -          sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> -          sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront),\n> -\n> -          # This is the function that will be used to average the pixels in\n> -          # each sector. This can also be a custom function.\n> -          sector_average_function=lt.average.Mean(),\n> -\n> -          # This is the function that will be used to smooth the color ratio\n> -          # values.  This can also be a custom function.\n> -          smoothing_function=lt.smoothing.MedianBlur(3),\n> -          ))\n> +tuner.add(lsc)\n>  \n>  tuner.set_input_parser(YamlParser())\n>  tuner.set_output_formatter(YamlOutput())\n> -tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing,\n> -                        filter, gamma_out, LSCRkISP1])\n> +tuner.set_output_order([agc, awb, blc, ccm, color_processing,\n> +                        filter, gamma_out, lsc])\n>  \n>  if __name__ == '__main__':\n>      sys.exit(tuner.run(sys.argv))\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 697F8C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 14 Aug 2024 07:54:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 59C10633B9;\n\tWed, 14 Aug 2024 09:54:53 +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 C451861946\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Aug 2024 09:54:51 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-024.catv02.itscom.jp\n\t[175.177.49.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 454036B5;\n\tWed, 14 Aug 2024 09:53:53 +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=\"NItA8+d0\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723622034;\n\tbh=S2BUTUN5FXLrC+lqOd79FxLVHv+8HYFoC8vRPTBn51Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NItA8+d0oc5ISukVM1QINjKaXQHVPCWrjcMtWc1QtBMgcICJVNEYxhCH6vQ+x5LeZ\n\tFxwPMsnz6VqB8NuCNnfNhxG9m+HhdMgyck/Hyj4zPqRfYvSAqZpORgE3AFnnPSvyg8\n\twSp3d25Zz6sl8Z9aqrCwsPJDYhBSusb6WtCvlMAw=","Date":"Wed, 14 Aug 2024 16:54:43 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/2] utils: tuning: rkisp1: Clean up tuner\n\tconstruction","Message-ID":"<Zrxiw6gM3tfO70dg@pyrite.rasen.tech>","References":"<20240805070644.1536232-1-stefan.klug@ideasonboard.com>\n\t<20240805070644.1536232-2-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240805070644.1536232-2-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>"}}]