Patch Detail
Show a patch.
GET /api/patches/17872/?format=api
{ "id": 17872, "url": "https://patchwork.libcamera.org/api/patches/17872/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17872/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20221124113550.2182342-7-paul.elder@ideasonboard.com>", "date": "2022-11-24T11:35:44", "name": "[libcamera-devel,v4,06/12] utils: libtuning: modules: alsc: Add rkisp1 LSC module", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "8f5a3a14c9d6d4364d3ff3b5540716a22f04cbcf", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17872/mbox/", "series": [ { "id": 3636, "url": "https://patchwork.libcamera.org/api/series/3636/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3636", "date": "2022-11-24T11:35:38", "name": "utils: tuning: Add a new tuning infrastructure", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3636/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17872/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17872/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 1E5BCBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 11:36:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DCDE26331A;\n\tThu, 24 Nov 2022 12:36:14 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0575663319\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 12:36:13 +0100 (CET)", "from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C2987FA;\n\tThu, 24 Nov 2022 12:36:11 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669289774;\n\tbh=68JvHufpiKs5rWAWg3nqZTiEXti5vbOJntMnvfKr6qA=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=qlP1odPN1YmF0Oi/ql+PwQJGSYgmLaY8iDUrz6zsgK8Ndhxyy9l2iYF0HWTyM1/RN\n\tFlIJbl2g0fKU8RYYKPoK5Sx8PYhQOfohghZXgtl38YGikOBqGoaF6tw/xtQhJ9C1gJ\n\tCkR9g1fSBL1iTOJzWGBjGR1P8tlF1jdGqvLF39VlX+R5vueK7Kp6GGxyHD7+iRs8XT\n\tOhRsMbBW/FqleYM2PeuVP/4ts6lCsLOQ2NeVY+97bBc9JfqlWD6EmkQ8U0QeJ9xuO8\n\tQXTlrlSPCE6evEQMQUVzuGPzOVAUt78Vbyfh8mP9amWvmKHR0hZIqfcMImP7lrOf2T\n\tl0c10FgIt7hrg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669289772;\n\tbh=68JvHufpiKs5rWAWg3nqZTiEXti5vbOJntMnvfKr6qA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qsqLaKRSaFAKWlFyySelOFkIkjQ4y/SPAP15aa/6d3raQJy+NbNBTlhrFKey4ViOD\n\tQFbBgrvK9Q52wp2CWxqnNC55hvSVhSgDIwFdo5Q0GI0gFhdHROOTORHzmgI280NROx\n\t5EdbutxrOVzHm+va66Ha2gCBMojSUyhKUipUQJNc=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"qsqLaKRS\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 24 Nov 2022 20:35:44 +0900", "Message-Id": "<20221124113550.2182342-7-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20221124113550.2182342-1-paul.elder@ideasonboard.com>", "References": "<20221124113550.2182342-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 06/12] utils: libtuning: modules: alsc:\n\tAdd rkisp1 LSC module", "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>", "From": "Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Paul Elder <paul.elder@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add an LSC module for RkISP1.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v4:\n- remove cli args from module.process parameters\n- inline output_map_func parameters as they are only used once\n\nChanges in v3:\n- rename ALSC to LSC\n- add file description\n\nNew in v2\n---\n .../tuning/libtuning/modules/lsc/__init__.py | 1 +\n utils/tuning/libtuning/modules/lsc/rkisp1.py | 112 ++++++++++++++++++\n 2 files changed, 113 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/lsc/rkisp1.py", "diff": "diff --git a/utils/tuning/libtuning/modules/lsc/__init__.py b/utils/tuning/libtuning/modules/lsc/__init__.py\nindex 7cdecdb8..0ba4411b 100644\n--- a/utils/tuning/libtuning/modules/lsc/__init__.py\n+++ b/utils/tuning/libtuning/modules/lsc/__init__.py\n@@ -4,3 +4,4 @@\n \n from libtuning.modules.lsc.lsc import LSC\n from libtuning.modules.lsc.raspberrypi import ALSCRaspberryPi\n+from libtuning.modules.lsc.rkisp1 import LSCRkISP1\ndiff --git a/utils/tuning/libtuning/modules/lsc/rkisp1.py b/utils/tuning/libtuning/modules/lsc/rkisp1.py\nnew file mode 100644\nindex 00000000..5701ae0a\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/lsc/rkisp1.py\n@@ -0,0 +1,112 @@\n+# SPDX-License-Identifier: BSD-2-Clause\n+#\n+# Copyright (C) 2019, Raspberry Pi Ltd\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# rkisp1.py - LSC module for tuning rkisp1\n+\n+from .lsc import LSC\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+from numbers import Number\n+import numpy as np\n+\n+\n+class LSCRkISP1(LSC):\n+ hr_name = 'LSC (RkISP1)'\n+ out_name = 'LensShadingCorrection'\n+ # \\todo Not sure if this is useful. Probably will remove later.\n+ compatible = ['rkisp1']\n+\n+ def __init__(self, *args, **kwargs):\n+ super().__init__(**kwargs)\n+\n+ # We don't actually need anything from the config file\n+ def validate_config(self, config: dict) -> bool:\n+ return True\n+\n+ # @return Image color temperature, flattened array of red calibration table\n+ # (containing {sector size} elements), flattened array of blue\n+ # calibration table, flattened array of (red's) green calibration\n+ # table, flattened array of (blue's) green calibration table\n+\n+ def _do_single_lsc(self, image: lt.Image):\n+ cgr, gr = self._lsc_single_channel(image.channels[lt.Color.GR], image)\n+ cgb, gb = self._lsc_single_channel(image.channels[lt.Color.GB], image)\n+\n+ # \\todo Should these ratio against the average of both greens or just\n+ # each green like we've done here?\n+ cr, _ = self._lsc_single_channel(image.channels[lt.Color.R], image, gr)\n+ cb, _ = self._lsc_single_channel(image.channels[lt.Color.B], image, gb)\n+\n+ return image.color, cr.flatten(), cb.flatten(), cgr.flatten(), cgb.flatten()\n+\n+ # @return List of dictionaries of color temperature, red table, red's green\n+ # table, blue's green table, and blue table\n+\n+ def _do_all_lsc(self, images: list) -> list:\n+ output_list = []\n+ output_map_func = lt.gradient.Linear().map\n+\n+ # List of colour temperatures\n+ list_col = []\n+ # Associated calibration tables\n+ list_cr = []\n+ list_cb = []\n+ list_cgr = []\n+ list_cgb = []\n+ for image in self._enumerate_lsc_images(images):\n+ col, cr, cb, cgr, cgb = self._do_single_lsc(image)\n+ list_col.append(col)\n+ list_cr.append(cr)\n+ list_cb.append(cb)\n+ list_cgr.append(cgr)\n+ list_cgb.append(cgb)\n+\n+ # Convert to numpy array for data manipulation\n+ list_col = np.array(list_col)\n+ list_cr = np.array(list_cr)\n+ list_cb = np.array(list_cb)\n+ list_cgr = np.array(list_cgr)\n+ list_cgb = np.array(list_cgb)\n+\n+ for color_temperature in sorted(set(list_col)):\n+ # Average tables for the same colour temperature\n+ indices = np.where(list_col == color_temperature)\n+ color_temperature = int(color_temperature)\n+\n+ tables = []\n+ for lis in [list_cr, list_cgr, list_cgb, list_cb]:\n+ table = np.mean(lis[indices], axis=0)\n+ table = output_map_func((1, 3.999), (1024, 4095), table)\n+ table = np.round(table).astype('int32').tolist()\n+ tables.append(table)\n+\n+ entry = {\n+ 'ct': color_temperature,\n+ 'r': tables[0],\n+ 'gr': tables[1],\n+ 'gb': tables[2],\n+ 'b': tables[3],\n+ }\n+\n+ output_list.append(entry)\n+\n+ return output_list\n+\n+ def process(self, config: dict, images: list, outputs: dict) -> dict:\n+ output = {}\n+\n+ # \\todo This should actually come from self.sector_{x,y}_gradient\n+ size_gradient = lt.gradient.Linear(lt.Remainder.Float)\n+ output['x-size'] = size_gradient.distribute(0.5, 8)\n+ output['y-size'] = size_gradient.distribute(0.5, 8)\n+\n+ output['sets'] = self._do_all_lsc(images)\n+\n+ # \\todo Validate images from greyscale camera and force grescale mode\n+ # \\todo Debug functionality\n+\n+ return output\n", "prefixes": [ "libcamera-devel", "v4", "06/12" ] }