Patch Detail
Show a patch.
GET /api/1.1/patches/17870/?format=api
{ "id": 17870, "url": "https://patchwork.libcamera.org/api/1.1/patches/17870/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17870/", "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": "<20221124113550.2182342-5-paul.elder@ideasonboard.com>", "date": "2022-11-24T11:35:42", "name": "[libcamera-devel,v4,04/12] utils: libtuning: modules: Add base LSC module", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "04dac79219f4ef1ffc79a7611540e511662ce0cd", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17870/mbox/", "series": [ { "id": 3636, "url": "https://patchwork.libcamera.org/api/1.1/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/17870/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17870/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 2C103BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Nov 2022 11:36:11 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EDE166331B;\n\tThu, 24 Nov 2022 12:36:10 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4373F63321\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Nov 2022 12:36:09 +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 B8EFD496;\n\tThu, 24 Nov 2022 12:36:07 +0100 (CET)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1669289770;\n\tbh=3cdWwHM8Ia0AWP/tCkVhKltnyHW7TVzU9UusVKHhod0=;\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=2SSRQP+iTc3ZCvEHOr14WyTjJflUNosCb9g2lFxzRCMlALpl6DlRm9GRY4wBP8otX\n\tEMvBJUlvAutgb5/qlTwBeJWmA+4fCJveNidKalL/HNXSdzAFpy2z0mZ+3K1Ear0VZx\n\tyDzTHgPnXq/iozMtxu/iARipV91IUCeP4U5yxeV6jpcQC6S3o5KOmEOo8MWYJW2En8\n\tIJopttRvWzpqggVjqpcZmgPg7/W0LOm2bLiMTAFxnmINlH5x1ByGqJlb1ZySDbwyae\n\t16PDI1TOCN7cfYqQxEsSObG112VQ4MGXj0p0qGHeDjr8FXgxVD8w/6ClWP/+7JgBbD\n\tULRZQDVLcL8ZA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1669289769;\n\tbh=3cdWwHM8Ia0AWP/tCkVhKltnyHW7TVzU9UusVKHhod0=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TMMGqd3lfJK8tvgoVbAR4XGONNKdGq2bP8getL3UR+BMshtxpQ/Bjii0HPlNdNdvJ\n\tX1jWl48JdLSq1NJ2if6vEb0cowarb4/cMRegzh9VQLFCw232wW3PuEke46V5Awzx/R\n\tsTj4vuv1L7e9f0SDc73NMNMkmjb9eo1gkaZJNffc=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"TMMGqd3l\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 24 Nov 2022 20:35:42 +0900", "Message-Id": "<20221124113550.2182342-5-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 04/12] utils: libtuning: modules: Add\n\tbase 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 a base LSC module to libtuning's collection of modules. It is based\non raspberrypi's ctt's ALSC, but customizable for different lens shading\ntable sizes, among other things. It alone is insufficient as a module,\nbut it provides utilities that are useful for and which will simplify\nimplementing LSC modules.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v3:\n- rename ALSC to LSC\n- update changelog to more accurately reflect the redesign (splitting\n core LSC from Raspberry Pi ALSC and rkisp1 LSC)\n\nChanges in v2:\n- fix python errors\n- fix style\n- add SPDX and copyright\n- don't call super().validateConfig()\n- fix sector splitting\n - i forgot that we have to half the image size for each color channel\n- make the base ALSC module into an abstract module, which can be easily\n used by other platforms to derive their own ALSC modules (see rkisp1's\n module later in this series; i think it's quite nice)\n---\n .../tuning/libtuning/modules/lsc/__init__.py | 5 ++\n utils/tuning/libtuning/modules/lsc/lsc.py | 72 +++++++++++++++++++\n 2 files changed, 77 insertions(+)\n create mode 100644 utils/tuning/libtuning/modules/lsc/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/lsc/lsc.py", "diff": "diff --git a/utils/tuning/libtuning/modules/lsc/__init__.py b/utils/tuning/libtuning/modules/lsc/__init__.py\nnew file mode 100644\nindex 00000000..47d9b846\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/lsc/__init__.py\n@@ -0,0 +1,5 @@\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# Copyright (C) 2022, Paul Elder <paul.elder@ideasonboard.com>\n+\n+from libtuning.modules.lsc.lsc import LSC\ndiff --git a/utils/tuning/libtuning/modules/lsc/lsc.py b/utils/tuning/libtuning/modules/lsc/lsc.py\nnew file mode 100644\nindex 00000000..344a07a3\n--- /dev/null\n+++ b/utils/tuning/libtuning/modules/lsc/lsc.py\n@@ -0,0 +1,72 @@\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+from ..module import Module\n+\n+import libtuning as lt\n+import libtuning.utils as utils\n+\n+import numpy as np\n+\n+\n+class LSC(Module):\n+ type = 'lsc'\n+ hr_name = 'LSC (Base)'\n+ out_name = 'GenericLSC'\n+\n+ def __init__(self, *,\n+ debug: list,\n+ sector_shape: tuple,\n+ sector_x_gradient: lt.Gradient,\n+ sector_y_gradient: lt.Gradient,\n+ sector_average_function: lt.Average,\n+ smoothing_function: lt.Smoothing):\n+ super().__init__()\n+\n+ self.debug = debug\n+\n+ self.sector_shape = sector_shape\n+ self.sector_x_gradient = sector_x_gradient\n+ self.sector_y_gradient = sector_y_gradient\n+ self.sector_average_function = sector_average_function\n+\n+ self.smoothing_function = smoothing_function\n+\n+ def _enumerate_lsc_images(self, images):\n+ for image in images:\n+ if image.lsc_only:\n+ yield image\n+\n+ def _get_grid(self, channel, img_w, img_h):\n+ # List of number of pixels in each sector\n+ sectors_x = self.sector_x_gradient.distribute(img_w / 2, self.sector_shape[0])\n+ sectors_y = self.sector_y_gradient.distribute(img_h / 2, self.sector_shape[1])\n+\n+ grid = []\n+\n+ r = 0\n+ for y in sectors_y:\n+ c = 0\n+ for x in sectors_x:\n+ grid.append(self.sector_average_function.average(channel[r:r + y, c:c + x]))\n+ c += x\n+ r += y\n+\n+ return np.array(grid)\n+\n+ def _lsc_single_channel(self, channel: np.array,\n+ image: lt.Image, green_grid: np.array = None):\n+ grid = self._get_grid(channel, image.w, image.h)\n+ grid -= image.blacklevel_16\n+ if green_grid is None:\n+ table = np.reshape(1 / grid, self.sector_shape[::-1])\n+ else:\n+ table = np.reshape(green_grid / grid, self.sector_shape[::-1])\n+ table = self.smoothing_function.smoothing(table)\n+\n+ if green_grid is None:\n+ table = table / np.min(table)\n+\n+ return table, grid\n", "prefixes": [ "libcamera-devel", "v4", "04/12" ] }