From patchwork Sat Oct 22 06:23:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17662 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 8E5D2C3285 for ; Sat, 22 Oct 2022 06:23:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 35E2062EE7; Sat, 22 Oct 2022 08:23:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1666419822; bh=jgWGfEWaME0hSQK8FMruyWsBu04/S6Vs0ytIaFyiGoQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GkdARBNx78qRL2GelUhLqmAlaqsuYDM625H86s08PBqkPGpy69Dcyu45Z1FUB+JZu C3AIuMNpsTHVLaFwX8L4vm++018Af/wVzMCCkMefYYQXtsd75aU/R5sCLg0CyX9/ic BUda93VVX07L9W0rWAwAXDR5vkK0+MMonlh9fzLIJs3H5OlapA1g75Juha9Mdl/kyK m8Fx78/Zdh6GGzrC+yHlVCMERRvRAXFmfhSf+K48Z9PLW52V1LFOg2VlD44lC89hxC IymewB7wX7eSm5QZ1ueSsxgaLi+raVSnUMBrtmXW0DXTfBu306dcPNIvony/eZ2mOq 9E1iYWSH5Pd6Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 47F2E62EDF for ; Sat, 22 Oct 2022 08:23:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t4I00rWi"; dkim-atps=neutral Received: from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1664D891; Sat, 22 Oct 2022 08:23:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1666419820; bh=jgWGfEWaME0hSQK8FMruyWsBu04/S6Vs0ytIaFyiGoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4I00rWipHC8siTxpkPEQ1AgkUpF9nB7jfXl0GFlkp8IWjhQHnXoUazq47ZR6SJg4 0z3H5XeA/cjjQqdw+hgXVW4mpGrx6HWgMylxFde61H6F+mDkQ7sKQF/Q1X/Ye3AKCN 9+QFIB3r5RMwrI4FS//Tm6IAnxXz5gZ9B109bruY= To: libcamera-devel@lists.libcamera.org Date: Sat, 22 Oct 2022 15:23:10 +0900 Message-Id: <20221022062310.2545463-12-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221022062310.2545463-1-paul.elder@ideasonboard.com> References: <20221022062310.2545463-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 11/11] [WIP] utils: tuning: Add tuning script for rkisp1 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a tuning script for rkisp1 that uses libtuning. Signed-off-by: Paul Elder --- Changes in v2: - add SPDX and copyright - s/average_functions/average/ - update the script to work with the new rkisp1 alsc module As of v2, this runs, but only with LSC. Parabolic gradient support is put on hold, and instead the sectors are divided linearly. Is this what we want? Technically this script is complete in the sense that it works, but it's still WIP because it only support LSC. What should we do about this? Should it be "complete" at this stage and we can add the other modules later, or should we keep it WIP until the other modules are added? v1: This won't run as we're missing the necessary parser and generator for yaml, parabolic gradient support, and multiple green support in the LSC module, hence the DNI. As soon as those are added though, this *should* work. --- utils/tuning/rkisp1.py | 58 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 utils/tuning/rkisp1.py diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py new file mode 100755 index 00000000..cb692dd1 --- /dev/null +++ b/utils/tuning/rkisp1.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022, Paul Elder +# +# rkisp1.py - Tuning script for rkisp1 + +import sys + +import libtuning as lt +from libtuning.parsers import YamlParser +from libtuning.generators import YamlOutput +from libtuning.modules.alsc import ALSCRkISP1 + +tuner = lt.Camera('RkISP1') +tuner.add(ALSCRkISP1( + # This can support other debug options (I can't think of any rn + # but for future-proofing) + debug=[lt.Debug.Plot], + + # This is for the actual LSC tuning, and is part of the base + # ALSC module. rkisp1's table size (16x16 programmed as mirrored + # 8x8) is separate, and is hardcoded in its specific ALSC tuning + # module + sector_shape=(17, 17), + + # Other functions might include Circular, Hyperbolic, Gaussian, + # Linear, Exponential, Logarithmic, etc + # Of course, both need not be the same function + # Some functions would need a sector_x_parameter (eg. sigma for Gaussian) + # Alternatively: sector_x_sizes = [] ? I don't think it would work tho + 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), + + # Do we need a flag to enable/disable calculating sigmas? afaik + # the rkisp1 IPA doesn't use it? But we could output it anyway + # and algorithms can decide whether or not if they want to use + # it. Oh well, no flag for now, we can always add it later if + # there's a big demand, plus it's only two to three values and + # not an entire table. + )) +tuner.setInputType(YamlParser) +tuner.setOutputType(YamlOutput) +tuner.setOutputOrder([ALSCRkISP1]) + +# Maybe this should be wrapped in an if __main__ = '__main__' ? That way the +# developer can control which tuner they want to be executed based on another +# layer of arguments? But I was thinking that this would handle *all* arguments +# based on the modules' and the input/output configurations. +tuner.run(sys.argv)