{"id":20483,"url":"https://patchwork.libcamera.org/api/1.1/patches/20483/?format=json","web_url":"https://patchwork.libcamera.org/patch/20483/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240628104828.2928109-25-stefan.klug@ideasonboard.com>","date":"2024-06-28T10:47:17","name":"[v2,24/25] tuning: rkisp1: Add blc module","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"eec41a3f827c1ba7ba54d139d404cfd59766df77","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20483/mbox/","series":[{"id":4430,"url":"https://patchwork.libcamera.org/api/1.1/series/4430/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4430","date":"2024-06-28T10:46:53","name":"Add ccm calibration to libtuning","version":2,"mbox":"https://patchwork.libcamera.org/series/4430/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20483/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20483/checks/","tags":{},"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 82065BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Jun 2024 10:49:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4AE156336C;\n\tFri, 28 Jun 2024 12:49:48 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F8BB63364\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Jun 2024 12:49:47 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:82ab:924:d918:cd24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A7D4E735;\n\tFri, 28 Jun 2024 12:49:22 +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=\"gwlGGlG4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719571762;\n\tbh=OZynHxtHvtOP2y6/P4KUZDzQfRdZp4JFW6FPmMmpwZA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gwlGGlG4F3pgI0R7+nruzmnUah+2v6pP9GWw4tfx2kRsYnzWuYcrMF/rj3GlOknqZ\n\tJ6tDO0+topLDIUDflucwsWIFdmC5QyYaToQqj4ykJw2tgIoC+19gc5wc+bsj2o8a+K\n\tsStHLcCbNzBoN9IbyrMcm3mXXsA4JaLDwohY/XkM=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH v2 24/25] tuning: rkisp1: Add blc module","Date":"Fri, 28 Jun 2024 12:47:17 +0200","Message-ID":"<20240628104828.2928109-25-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>","References":"<20240628104828.2928109-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"This module simple copies the values from the tuning images into the\ntuning file.\n\nSigned-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","diff":"diff --git a/utils/tuning/libtuning/modules/blc/__init__.py b/utils/tuning/libtuning/modules/blc/__init__.py\nnew file mode 100644\nindex 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\ndiff --git a/utils/tuning/libtuning/modules/blc/blc.py b/utils/tuning/libtuning/modules/blc/blc.py\nnew file mode 100644\nindex 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\ndiff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py\nindex 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))\n","prefixes":["v2","24/25"]}