From patchwork Thu Oct 6 12:01:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 17540 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 748A3C0DA4 for ; Thu, 6 Oct 2022 12:01:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2798662D01; Thu, 6 Oct 2022 14:01:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665057693; bh=MsJfSHZA+x99EnG652uupmIyLe/hzEKsaP1x+7Nlgfk=; 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=X4Ol/wxi7c0osJgxpuF3+Z/j0e3dk7UmzvXw4E3gEAfBa0u8IR2LtNxIPGGGAcEpq nBtRY6jOAnhA81zRqSMBADE7gdjTo+R/REoGXGiRXPEBVl/MkrrOmqPtrwJ6r2SJ8d 9W7l+wTtBjQQTKGUN4fd3VrZ9xTwzX0Hpy2K9dxQz47cMkIOneGFtfhSKisHVNfix4 zInV4KRcjvAfmYUG0GJchTcdlh7gG0DjbO64T9ZFrWgNwNdEqHGqKL/LBVd27+40el bqoI4O6KiV9aYQs79kmckh8wrX1en/8jWH+GoNDVIqU0dTYovdkqbhb/52y4Usdv2a JVG0htAWfP09w== 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 5970162CFE for ; Thu, 6 Oct 2022 14:01:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ok1GZZLr"; 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 EBA624DD; Thu, 6 Oct 2022 14:01:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665057691; bh=MsJfSHZA+x99EnG652uupmIyLe/hzEKsaP1x+7Nlgfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ok1GZZLrnGD9uGMrG/RH8d7/ftttz9lO5ddyPPL+rsikyIzm/j6bxpBFa8PItTtPK gKcDSVqC9HWn3kDPE7LLXZZVusjqICYqv5LDbkJtbgftvl0nYHto8yfQGYhA/78suN bp5DNlRa8lEMjYjQ22wStkGLOukobl3YYcxu9l70= To: libcamera-devel@lists.libcamera.org Date: Thu, 6 Oct 2022 21:01:05 +0900 Message-Id: <20221006120105.3861831-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221006120105.3861831-1-paul.elder@ideasonboard.com> References: <20221006120105.3861831-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 7/7] [DNI] 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 --- This won't run as we're missing the necessary parser and generator for yaml, parabolic gradient support, and multiple green support in the ALSC module, hence the DNI. As soon as those are added though, this *should* work. --- utils/tuning/rkisp1.py | 69 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 utils/tuning/rkisp1.py diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py new file mode 100644 index 00000000..6ccd8ceb --- /dev/null +++ b/utils/tuning/rkisp1.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 + +import sys + +import libtuning as lt +from libtuning.modules import ALSC +from libtuning.parsers import YamlParser +from libtuning.generators import YamlOutput + +tuner = lt.Camera('RkISP1') +tuner.add(ALSC(do_color=lt.param('do_alsc_colour', lt.param.mode.Optional, True), + + # This can support other debug options (I can't think of any rn + # but for future-proofing) + debug=[lt.debug.Plot], + + # The name of IfUnSet can obviously be changed, but really I + # just want something that says "it must be specified in the + # configuration, and get the value from there" or "if the value + # is not in the configuration, use this" + luminance_strength=lt.param('luminance_strength', lt.param.mode.Optional, 0.5), + + sector_shape=(16, 16), + + # 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.Parabolic, + sector_y_gradient=lt.gradient.Parabolic, + + # 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_functions.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, + smoothing_parameters=[3], + + # Are there any platforms that use integer values for their lsc table? + output_type=lt.type.Float, + + # Required if and only if do_color can be or is True + output_color_channels=[lt.color.R, lt.color.GR, lt.color.GB, lt.color.B], + + # Required if and only if do_color can be or is False + output_luminance_channels=[lt.color.GR, lt.color.GB], + + # Automatically get the precision from this + output_range=(0, 3.999) + + # 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([ALSC]) + +# 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)