Show a patch.

GET /api/1.1/patches/20898/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 20898,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/20898/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/20898/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20240813084451.44099-6-stefan.klug@ideasonboard.com>",
    "date": "2024-08-13T08:44:22",
    "name": "[v4,5/6] libtuning: Add initial AWB module",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b66032472baaa938ee898eecee4de98f299e78b5",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/20898/mbox/",
    "series": [
        {
            "id": 4514,
            "url": "https://patchwork.libcamera.org/api/1.1/series/4514/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4514",
            "date": "2024-08-13T08:44:17",
            "name": "rkisp1: Add manual colour temperature control",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/4514/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/20898/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/20898/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 7DE8EC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 13 Aug 2024 08:45:19 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2B068633C5;\n\tTue, 13 Aug 2024 10:45:19 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BFBFC633C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 13 Aug 2024 10:45:16 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:7025:8d00:1ffd:751a])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DF9FD827;\n\tTue, 13 Aug 2024 10:44:19 +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=\"gA9IvLHC\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723538660;\n\tbh=V9Oha5C3YDbyGAPUEltpK+alEolxP0AseaHmNlRfq6s=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=gA9IvLHCfHctNFtjawOTMalMKIUh/3nH1NbC6Bah8+MBRzg1v6o4raw5A54X+wYZK\n\tl/nc6g3gfOH3+oCWzyZEzf7BMYEnJFtm/V33Y6DsbH6Y0Soa1C05qx1LsfI/az27Pr\n\tJJdoqwBRNcGC4LcaxwVeLVhsdXtRTfwsrPQ/l9B8=",
        "From": "Stefan Klug <stefan.klug@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>",
        "Subject": "[PATCH v4 5/6] libtuning: Add initial AWB module",
        "Date": "Tue, 13 Aug 2024 10:44:22 +0200",
        "Message-ID": "<20240813084451.44099-6-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240813084451.44099-1-stefan.klug@ideasonboard.com>",
        "References": "<20240813084451.44099-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 AWB modules uses the awb function from Raspberry Pi to calculate\nthe needed white balance gains per colour temperature. It stores these\ngains in the tuning file. Currently they are only used for the manual\ncolour temperature control. It is likely that they will be used with\nmore complex awb algorithms.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n .../tuning/libtuning/modules/awb/__init__.py  |  6 +++\n utils/tuning/libtuning/modules/awb/awb.py     | 42 +++++++++++++++++++\n utils/tuning/libtuning/modules/awb/rkisp1.py  | 27 ++++++++++++\n 3 files changed, 75 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/awb/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/awb/awb.py\n create mode 100644 utils/tuning/libtuning/modules/awb/rkisp1.py",
    "diff": "diff --git a/utils/tuning/libtuning/modules/awb/__init__.py b/utils/tuning/libtuning/modules/awb/__init__.py\nnew file mode 100644\nindex 000000000000..2d67f10cfc4f\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/awb/__init__.py\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2024, Ideas On Board\n+\n+from libtuning.modules.awb.awb import AWB\n+from libtuning.modules.awb.rkisp1 import AWBRkISP1\ndiff --git a/utils/tuning/libtuning/modules/awb/awb.py b/utils/tuning/libtuning/modules/awb/awb.py\nnew file mode 100644\nindex 000000000000..5680a44fd3e3\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/awb/awb.py\n@@ -0,0 +1,42 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2024, Ideas On Board\n+\n+import logging\n+\n+from ..module import Module\n+\n+from libtuning.ctt_awb import awb\n+import numpy as np\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+class AWB(Module):\n+    type = 'awb'\n+    hr_name = 'AWB (Base)'\n+    out_name = 'GenericAWB'\n+\n+    def __init__(self, *,\n+                 debug: list):\n+        super().__init__()\n+\n+        self.debug = debug\n+\n+    def do_calculation(self, images):\n+        logger.info('Starting AWB calculation')\n+\n+        imgs = [img for img in images if img.macbeth is not None]\n+\n+        gains, _, _ = awb(imgs, None, None, False)\n+        gains = np.array(gains)\n+        gains = gains.reshape(-1, 3)\n+\n+        res = []\n+        for v in gains:\n+            res.append({\n+                'ct': int(v[0]),\n+                'gains': [float(1.0 / v[1]), float(1.0 / v[2])]\n+            })\n+\n+        return res\ndiff --git a/utils/tuning/libtuning/modules/awb/rkisp1.py b/utils/tuning/libtuning/modules/awb/rkisp1.py\nnew file mode 100644\nindex 000000000000..e3ddeb50c9a1\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/awb/rkisp1.py\n@@ -0,0 +1,27 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2024, Ideas On Board\n+#\n+# AWB module for tuning rkisp1\n+\n+from .awb import AWB\n+\n+import libtuning as lt\n+\n+\n+class AWBRkISP1(AWB):\n+    hr_name = 'AWB (RkISP1)'\n+    out_name = 'Awb'\n+\n+    def __init__(self, **kwargs):\n+        super().__init__(**kwargs)\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+        output['gains'] = self.do_calculation(images)\n+\n+        return output\n",
    "prefixes": [
        "v4",
        "5/6"
    ]
}