[{"id":30148,"web_url":"https://patchwork.libcamera.org/comment/30148/","msgid":"<20240629010858.GV30900@pendragon.ideasonboard.com>","date":"2024-06-29T01:08:58","subject":"Re: [PATCH v2 24/25] tuning: rkisp1: Add blc module","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Stefan,\n\nThank you for the patch.\n\nOn Fri, Jun 28, 2024 at 12:47:17PM +0200, Stefan Klug wrote:\n> This module simple copies the values from the tuning images into the\n> tuning file.\n\nAs explained in the review of 24/25, I don't think this is correct.\n\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  .../tuning/libtuning/modules/blc/__init__.py  |  5 ++\n>  utils/tuning/libtuning/modules/blc/blc.py     | 46 +++++++++++++++++++\n>  utils/tuning/rkisp1.py                        |  4 +-\n>  3 files changed, 54 insertions(+), 1 deletion(-)\n>  create mode 100644 utils/tuning/libtuning/modules/blc/__init__.py\n>  create mode 100644 utils/tuning/libtuning/modules/blc/blc.py\n> \n> diff --git a/utils/tuning/libtuning/modules/blc/__init__.py b/utils/tuning/libtuning/modules/blc/__init__.py\n> new file mode 100644\n> index 000000000000..33d4936e4cfd\n> --- /dev/null\n> +++ b/utils/tuning/libtuning/modules/blc/__init__.py\n> @@ -0,0 +1,5 @@\n> +# SPDX-License-Identifier: GPL-2.0-or-later\n> +#\n> +# Copyright (C) 2024, Ideas on Board Oy\n> +\n> +from .blc import BLC\n> diff --git a/utils/tuning/libtuning/modules/blc/blc.py b/utils/tuning/libtuning/modules/blc/blc.py\n> new file mode 100644\n> index 000000000000..8cfb80e53143\n> --- /dev/null\n> +++ b/utils/tuning/libtuning/modules/blc/blc.py\n> @@ -0,0 +1,46 @@\n> +# SPDX-License-Identifier: BSD-2-Clause\n> +#\n> +# Copyright (C) 2024, Ideas on Board Oy\n> +\n> +from ..module import Module\n> +import logging\n> +\n> +logger = logging.getLogger(__name__)\n> +\n> +\n> +class BLC(Module):\n> +    type = 'blc'\n> +    hr_name = 'BLC (Base)'\n> +    out_name = 'BlackLevelCorrection'\n> +\n> +    def __init__(self, debug: list):\n> +        super().__init__()\n> +\n> +        self.debug = debug\n> +\n> +    def validate_config(self, config: dict) -> bool:\n> +        return True\n> +\n> +    def process(self, config: dict, images: list, outputs: dict) -> dict:\n> +        output = {}\n> +\n> +        blacklevel = None\n> +\n> +        for img in images:\n> +            if blacklevel is None:\n> +                if img.blacklevel_16 > 0:\n> +                    blacklevel = img.blacklevel_16\n> +            else:\n> +                if img.blacklevel_16 > 0 and img.blacklevel_16 != blacklevel:\n> +                    logger.warnung(f\"Blacklevels differ {blacklevel} {img.blacklevel_16}\")\n> +\n> +        if blacklevel:\n> +            output['R'] = blacklevel\n> +            output['Gr'] = blacklevel\n> +            output['Gb'] = blacklevel\n> +            output['B'] = blacklevel\n> +            output['referenceBitwidth'] = 16\n> +            return output\n> +\n> +        logger.warning(\"No valid blacklevel found. Skipping blc\")\n> +        return None\n> diff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py\n> index c5036c65557b..7cf3f2f9fbf1 100755\n> --- a/utils/tuning/rkisp1.py\n> +++ b/utils/tuning/rkisp1.py\n> @@ -14,6 +14,7 @@ from libtuning.parsers import YamlParser\n>  from libtuning.generators import YamlOutput\n>  from libtuning.modules.lsc import LSCRkISP1\n>  from libtuning.modules.agc import AGCRkISP1\n> +from libtuning.modules.blc import BLC\n>  from libtuning.modules.ccm import CCMRkISP1\n>  from libtuning.modules.static import StaticModule\n>  \n> @@ -27,6 +28,7 @@ gamma_out = StaticModule('GammaOutCorrection', {'gamma': 2.2})\n>  tuner = lt.Tuner('RkISP1')\n>  tuner.add(AGCRkISP1(debug=[lt.Debug.Plot]))\n>  tuner.add(awb)\n> +tuner.add(BLC(debug=[lt.Debug.Plot]))\n>  tuner.add(CCMRkISP1(debug=[lt.Debug.Plot]))\n>  tuner.add(color_processing)\n>  tuner.add(filter)\n> @@ -53,7 +55,7 @@ tuner.add(LSCRkISP1(\n>  \n>  tuner.set_input_parser(YamlParser())\n>  tuner.set_output_formatter(YamlOutput())\n> -tuner.set_output_order([AGCRkISP1, awb, CCMRkISP1, color_processing, filter, gamma_out, LSCRkISP1])\n> +tuner.set_output_order([AGCRkISP1, awb, BLC, CCMRkISP1, color_processing, filter, gamma_out, LSCRkISP1])\n>  \n>  if __name__ == '__main__':\n>      sys.exit(tuner.run(sys.argv))","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 29945BDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 29 Jun 2024 01:09:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DC23619C7;\n\tSat, 29 Jun 2024 03:09:22 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4242B619C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Jun 2024 03:09:19 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A63B720;\n\tSat, 29 Jun 2024 03:08: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=\"f1Xjw+Bv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719623334;\n\tbh=Jibe2Eek9cwgp0PiPtF9RPF32EdS37I3PAY2P56CPA4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=f1Xjw+BvOHJ8/rs8/cY4mevup2SSofDFK+5kUVa2halC2p+eBbkbreT01nciDoS6N\n\tSNwXXVjKDORF5Zmo4Gg2pRq1Ot43xTIQhWLtjnR9FM0JA7mYoGE5SvLBgPFJtalom/\n\t4gY7iZ9wSZ5ORSUzYs7lsqmqUnWNqlB4xFe4llnU=","Date":"Sat, 29 Jun 2024 04:08:58 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 24/25] tuning: rkisp1: Add blc module","Message-ID":"<20240629010858.GV30900@pendragon.ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>\n\t<20240628104828.2928109-25-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628104828.2928109-25-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>"}}]