From patchwork Mon Aug 5 07:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20764 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 7394EBE173 for ; Mon, 5 Aug 2024 07:06:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2795163385; Mon, 5 Aug 2024 09:06:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uATgoNgm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D6F6863384 for ; Mon, 5 Aug 2024 09:06:52 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:30ff:e7b4:349c:44ce]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5620C1A2; Mon, 5 Aug 2024 09:06:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722841561; bh=ihSPB3tgeuEnj3LC1Yf6mjdTc2pY67dWI9L+r73YH/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uATgoNgmP0rVxIFxgmXDdeuG4kijXoWhZcgNLy/dk9NhI2oEEAd/l/qS7V4/FDVbd nxhYkCwM4N7S8OkK2nQXbXiKvFM8Zbhsd6fETrz9Lo6eAaV5r+kluRtrkNMSLYqRdI cpjT1608gGPZZtD9MgIUgHMQ1Al73oUo0FiyYgEU= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 1/2] utils: tuning: rkisp1: Clean up tuner construction Date: Mon, 5 Aug 2024 09:06:32 +0200 Message-ID: <20240805070644.1536232-2-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805070644.1536232-1-stefan.klug@ideasonboard.com> References: <20240805070644.1536232-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" The instances of the static modules need to be passed to tuner.set_output_order() instead of the class. This is the reason for the intermediate variables. To keep the code tidy, apply the same pattern to the other modules. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- utils/tuning/rkisp1.py | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py index 0d279a39ab1b..5d7a69fc4a13 100755 --- a/utils/tuning/rkisp1.py +++ b/utils/tuning/rkisp1.py @@ -19,44 +19,45 @@ from libtuning.modules.static import StaticModule coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s') +agc = AGCRkISP1(debug=[lt.Debug.Plot]) awb = StaticModule('Awb') blc = StaticModule('BlackLevelCorrection') +ccm = CCMRkISP1(debug=[lt.Debug.Plot]) color_processing = StaticModule('ColorProcessing') filter = StaticModule('Filter') gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2}) +lsc = LSCRkISP1(debug=[lt.Debug.Plot], + # This is for the actual LSC tuning, and is part of the base LSC + # module. rkisp1's table sector sizes (16x16 programmed as mirrored + # 8x8) are separate, and is hardcoded in its specific LSC tuning + # module. + sector_shape=(17, 17), + + sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + + # This is the function that will be used to average the pixels in + # each sector. This can also be a custom function. + sector_average_function=lt.average.Mean(), + + # This is the function that will be used to smooth the color ratio + # values. This can also be a custom function. + smoothing_function=lt.smoothing.MedianBlur(3),) tuner = lt.Tuner('RkISP1') -tuner.add(AGCRkISP1(debug=[lt.Debug.Plot])) +tuner.add(agc) tuner.add(awb) tuner.add(blc) -tuner.add(CCMRkISP1(debug=[lt.Debug.Plot])) +tuner.add(ccm) tuner.add(color_processing) tuner.add(filter) tuner.add(gamma_out) -tuner.add(LSCRkISP1( - debug=[lt.Debug.Plot], - # This is for the actual LSC tuning, and is part of the base LSC - # module. rkisp1's table sector sizes (16x16 programmed as mirrored - # 8x8) are separate, and is hardcoded in its specific LSC tuning - # module. - sector_shape=(17, 17), - - sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), - sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), - - # This is the function that will be used to average the pixels in - # each sector. This can also be a custom function. - sector_average_function=lt.average.Mean(), - - # This is the function that will be used to smooth the color ratio - # values. This can also be a custom function. - smoothing_function=lt.smoothing.MedianBlur(3), - )) +tuner.add(lsc) tuner.set_input_parser(YamlParser()) tuner.set_output_formatter(YamlOutput()) -tuner.set_output_order([AGCRkISP1, awb, blc, CCMRkISP1, color_processing, - filter, gamma_out, LSCRkISP1]) +tuner.set_output_order([agc, awb, blc, ccm, color_processing, + filter, gamma_out, lsc]) if __name__ == '__main__': sys.exit(tuner.run(sys.argv)) From patchwork Mon Aug 5 07:06:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20765 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 068AFBE173 for ; Mon, 5 Aug 2024 07:06:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B5C6563385; Mon, 5 Aug 2024 09:06:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IxnFZ9Zq"; 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 19CDD63380 for ; Mon, 5 Aug 2024 09:06:55 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:30ff:e7b4:349c:44ce]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D4C2DAB5; Mon, 5 Aug 2024 09:06:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1722841563; bh=nFyuMgK8ILHuUZ4eQQhEHNKAJrJ9TXW3HPnljwhSQaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxnFZ9ZqiMOV8z+qzAJcWOIdlLaGvLz4WFLtcO3CwD43p+BKkbL6MpJJa6zkcQTe8 7+2G19ooKctVv2ibcHNo3eHRhmstwAbov9hobiz9PTHssGuweJnWMt57M1C01DArXd mxAULCVZ2JpaTRh1xcrKf18LH8LnyKZZxIpLCxpE= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 2/2] utils: tuning: Change Tuner.add() to accept a list of modules Date: Mon, 5 Aug 2024 09:06:33 +0200 Message-ID: <20240805070644.1536232-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240805070644.1536232-1-stefan.klug@ideasonboard.com> References: <20240805070644.1536232-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" Change the first parameter of Tuner.add() to be a list of modules instead of a single module. This allows more compact code and is in sync with Tuner.set_output_order(). Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- utils/tuning/libtuning/libtuning.py | 4 ++-- utils/tuning/raspberrypi_alsc_only.py | 2 +- utils/tuning/rkisp1.py | 10 +--------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/utils/tuning/libtuning/libtuning.py b/utils/tuning/libtuning/libtuning.py index e7c63535fefd..a167e39ef08e 100644 --- a/utils/tuning/libtuning/libtuning.py +++ b/utils/tuning/libtuning/libtuning.py @@ -94,8 +94,8 @@ class Tuner(object): self.config = {} self.output = {} - def add(self, module): - self.modules.append(module) + def add(self, modules): + self.modules.extend(modules) def set_input_parser(self, parser): self.parser = parser diff --git a/utils/tuning/raspberrypi_alsc_only.py b/utils/tuning/raspberrypi_alsc_only.py index 777d800765e0..fe2b5b8b5a24 100755 --- a/utils/tuning/raspberrypi_alsc_only.py +++ b/utils/tuning/raspberrypi_alsc_only.py @@ -14,7 +14,7 @@ from libtuning.generators import RaspberryPiOutput from raspberrypi.alsc import ALSC tuner = lt.Tuner('Raspberry Pi (ALSC only)') -tuner.add(ALSC) +tuner.add([ALSC]) tuner.set_input_parser(RaspberryPiParser()) tuner.set_output_formatter(RaspberryPiOutput()) tuner.set_output_order([ALSC]) diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py index 5d7a69fc4a13..f5c42a61d15e 100755 --- a/utils/tuning/rkisp1.py +++ b/utils/tuning/rkisp1.py @@ -45,15 +45,7 @@ lsc = LSCRkISP1(debug=[lt.Debug.Plot], smoothing_function=lt.smoothing.MedianBlur(3),) tuner = lt.Tuner('RkISP1') -tuner.add(agc) -tuner.add(awb) -tuner.add(blc) -tuner.add(ccm) -tuner.add(color_processing) -tuner.add(filter) -tuner.add(gamma_out) -tuner.add(lsc) - +tuner.add([agc, awb, blc, ccm, color_processing, filter, gamma_out, lsc]) tuner.set_input_parser(YamlParser()) tuner.set_output_formatter(YamlOutput()) tuner.set_output_order([agc, awb, blc, ccm, color_processing,