Patch Detail
Show a patch.
GET /api/patches/17394/?format=api
{ "id": 17394, "url": "https://patchwork.libcamera.org/api/patches/17394/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17394/", "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": "<20220926050931.686428-1-paul.elder@ideasonboard.com>", "date": "2022-09-26T05:09:31", "name": "[libcamera-devel,RFC,RFC,DNI] utils: tuning: Draft a new tuning infrastructure", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "8a195737614e22654ea78d5c2ff3ed533d57994e", "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/17394/mbox/", "series": [ { "id": 3500, "url": "https://patchwork.libcamera.org/api/series/3500/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3500", "date": "2022-09-26T05:09:31", "name": "[libcamera-devel,RFC,RFC,DNI] utils: tuning: Draft a new tuning infrastructure", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3500/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17394/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17394/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 325BFC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Sep 2022 05:09:51 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F8A262247;\n\tMon, 26 Sep 2022 07:09:50 +0200 (CEST)", "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 A027A603DC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Sep 2022 07:09:49 +0200 (CEST)", "from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 068344F7;\n\tMon, 26 Sep 2022 07:09:46 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664168990;\n\tbh=z5wPVcp4Id5mk2x5bY5AU8zC3pjYCB0eR0EjwEEbse8=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=iEEYrw8ISVr3VGkzJEin4UMk0iyR099xbofYzXNilEsjQx9aF2uH4cKiD/ERduZU/\n\ted5Puvh191NzppJqGbjZhJSyQl3FOWw6cMiLL///suhM+MfbkZv2jHK+gmwoRkze4X\n\tDo1+U1Soi2zxTwOWMVAYuTa7bHRJLd0JFiMpPIkuV16jJIgaw1HPJR8euYxJWcO4+6\n\tLmaaVwveomQQ1B6IDjREee88eOGCZs+W9pppCwKDxf1f84MJpvESoGeen4333klm6E\n\tYrndGJdzFHxX4ilp9qUNj1GJD4+HSYjEY4aIfRQxfMIhmVSRuDGIRHOFru04eS1Mlo\n\tWX9PjiMNf+OHw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664168989;\n\tbh=z5wPVcp4Id5mk2x5bY5AU8zC3pjYCB0eR0EjwEEbse8=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=BlEHGO1guQcLY3cPyKvmkL1fmXDxzcw1Fw4i3Fcxj/pQvtUQduhWflU7fIqKji+3p\n\tG9lsv2rjPOw9CDa2sj966mX78gMGtuLjEMD+AsHFPEcX62ArAfGNIkIFqY5To3ZRHi\n\tASUpMizy9e/MgSBAeuXDeylMtVw4ds36RLLNhrPs=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BlEHGO1g\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 26 Sep 2022 14:09:31 +0900", "Message-Id": "<20220926050931.686428-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.30.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH] [RFC] [DNI] utils: tuning: Draft a\n\tnew tuning infrastructure", "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": "This patch introduces the interface of a new tuning infrastructure, with\nsamples of how I imagine different platforms would use it (aptly named\n\"libtuning\" for now) to create their own tuning scripts.\n\nThe samples include (in reverse order of how they appear in the patch,\nbut in semantic order of how I want to show them):\n- rkisp1, which for now only has ALSC, and comes with most of the\n descriptions in the form of comments\n- raspberrypi's alsc_only, which is similar to rkisp1's, to show how\n different platforms could implement similar-but-slightly-different\n tuning scripts without much duplication\n- raspberrypi's main one, which only has ALSC and a dummy AWB one for\n now\n\nThe two raspberrypi tuning scripts have a shared ALSC component, which\nis in a separate file to show where platforms could place custom\ncomponents if libtuning doesn't support exactly what the platform's\ntuning script wants.\n\nObviously none of this runs (hence the DNI) and none of it is\nimplemented yet, but I wanted to show how it would be used first and to\ngather comments on it.\n\nThere are some questions nested in the descriptions comments as well.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n utils/tuning/libtuning/__init__.py | 0\n utils/tuning/libtuning/modules/__init__.py | 0\n utils/tuning/raspberrypi.py | 37 ++++++++++++\n utils/tuning/raspberrypi/__init__.py | 0\n utils/tuning/raspberrypi/alsc.py | 16 ++++++\n utils/tuning/raspberrypi_alsc_only.py | 16 ++++++\n utils/tuning/rkisp1.py | 67 ++++++++++++++++++++++\n 7 files changed, 136 insertions(+)\n create mode 100644 utils/tuning/libtuning/__init__.py\n create mode 100644 utils/tuning/libtuning/modules/__init__.py\n create mode 100644 utils/tuning/raspberrypi.py\n create mode 100644 utils/tuning/raspberrypi/__init__.py\n create mode 100644 utils/tuning/raspberrypi/alsc.py\n create mode 100644 utils/tuning/raspberrypi_alsc_only.py\n create mode 100644 utils/tuning/rkisp1.py", "diff": "diff --git a/utils/tuning/libtuning/__init__.py b/utils/tuning/libtuning/__init__.py\nnew file mode 100644\nindex 00000000..e69de29b\ndiff --git a/utils/tuning/libtuning/modules/__init__.py b/utils/tuning/libtuning/modules/__init__.py\nnew file mode 100644\nindex 00000000..e69de29b\ndiff --git a/utils/tuning/raspberrypi.py b/utils/tuning/raspberrypi.py\nnew file mode 100644\nindex 00000000..322b9c36\n--- /dev/null\n+++ b/utils/tuning/raspberrypi.py\n@@ -0,0 +1,37 @@\n+import sys\n+\n+import libtuning as lt\n+from libtuning.modules import AWB\n+from libtuning.parsers import RaspberryPiParser\n+from libtuning.generators import RaspberryPiOutput\n+\n+from raspberrypi.alsc import ALSC as RaspberryPiALSC\n+\n+tuner = lt.Camera()\n+\n+# These modules can also be custom modules. libtuning will come with utilities\n+# for handling stuff like images, so there shouldn't be too much boilerplate\n+# involved in creating custom modules, though I don't yet have a concrete\n+# vision on how custom implementations of modules would look.\n+tuner.add(RaspberryPiALSC)\n+\n+# Other tuning modules can be added like so.\n+# The order that the tuning modules will be executed is determined by the order\n+# that they're added.\n+# This is kind of an implementation detail, but the \"context\" is saved\n+# internally in lt.Camera, so modules that are added (and therefore executed)\n+# later can use the output of the previous modules. I'm thinking that a module\n+# that depends on values from another module has two modes of execution, for\n+# when those values are available and another for when they're not. Not quite\n+# sure concretely how to handle this yet.\n+tuner.add(AWB( # module parameters\n+ ))\n+\n+tuner.setInputType(RaspberryPiParser)\n+tuner.setOutputType(RaspberryPiOutput)\n+\n+# The order of the output doesn't necessarily have to be the same as the order\n+# of input, which is specified by the order of adding the modules above.\n+tuner.setOutputOrder(AWB, ALSC)\n+\n+tuner.run(sys.argv)\ndiff --git a/utils/tuning/raspberrypi/__init__.py b/utils/tuning/raspberrypi/__init__.py\nnew file mode 100644\nindex 00000000..e69de29b\ndiff --git a/utils/tuning/raspberrypi/alsc.py b/utils/tuning/raspberrypi/alsc.py\nnew file mode 100644\nindex 00000000..ff8a02fd\n--- /dev/null\n+++ b/utils/tuning/raspberrypi/alsc.py\n@@ -0,0 +1,16 @@\n+ALSC(do_color = lt.paramsIfUnset(True), \\\n+ debug = [lt.debug.Plot], \\\n+ luminance_strength = lt.params.IfUnSet(0.5) \\\n+ sector_shape = (16, 12), \\\n+ sector_x_gradient = lt.gradients.Linear, \\\n+ sector_y_gradient = lt.gradients.Linear, \\\n+ sector_x_remainder = lt.remainder.Append, \\\n+ sector_y_remainder = lt.remainder.Append, \\\n+ sector_average_function = lt.average_functions.Mean, \\\n+ smoothing_function = lt.smoothing.MedianBlur, \\\n+ smoothing_parameters = [3], \\\n+ output_type = lt.type.Float, \\\n+ output_color_channels = [lt.color.R, lt.color.G, lt.color.B], \\\n+ output_luminance_channels = [lt.color.G] \\\n+ output_range = [0, 3.999] \\\n+ )\ndiff --git a/utils/tuning/raspberrypi_alsc_only.py b/utils/tuning/raspberrypi_alsc_only.py\nnew file mode 100644\nindex 00000000..11a1fc23\n--- /dev/null\n+++ b/utils/tuning/raspberrypi_alsc_only.py\n@@ -0,0 +1,16 @@\n+import sys\n+\n+import libtuning as lt\n+from libtuning.modules import ALSC\n+from libtuning.parsers import RaspberryPiParser\n+from libtuning.generators import RaspberryPiOutput\n+\n+from raspberrypi.alsc import ALSC as RaspberryPiALSC\n+\n+tuner = lt.Camera()\n+tuner.add(RaspberryPiALSC)\n+tuner.setInputType(RaspberryPiParser)\n+tuner.setOutputType(RaspberryPiOutput)\n+tuner.setOutputOrder(ALSC)\n+\n+tuner.run(sys.argv)\ndiff --git a/utils/tuning/rkisp1.py b/utils/tuning/rkisp1.py\nnew file mode 100644\nindex 00000000..8e26beba\n--- /dev/null\n+++ b/utils/tuning/rkisp1.py\n@@ -0,0 +1,67 @@\n+import sys\n+\n+import libtuning as lt\n+from libtuning.modules import ALSC\n+from libtuning.parsers import YamlParser\n+from libtuning.generators import YamlOutput\n+\n+tuner = lt.Camera()\n+tuner.add(ALSC(do_color = lt.paramsIfUnset(True), \\\n+\n+ # This can support other debug options (I can't think of any rn\n+ # but for future-proofing)\n+ debug = [lt.debug.Plot], \\\n+\n+ # The name of IfUnSet can obviously be changed, but really I\n+ # just want something that says \"it must be specified in the\n+ # configuration, and get the value from there\" or \"if the value\n+ # is not in the configuration, use this\"\n+ luminance_strength = lt.params.IfUnSet(0.5) \\\n+\n+ sector_shape = (16, 16), \\\n+\n+ # Other functions might include Circular, Hyperbolic, Gaussian,\n+ # Linear, Exponential, Logarithmic, etc\n+ # Of course, both need not be the same function\n+ # Some functions would need a sector_x_parameter (eg. sigma for Gaussian)\n+ # Alternatively: sector_x_sizes = [] ? I don't think it would work tho\n+ sector_x_gradient = lt.gradients.Parabolic, \\\n+ sector_y_gradient = lt.gradients.Parabolic, \\\n+\n+ # This is the function that will be used to average the pixels in each sector\n+ # This can also be a custom function.\n+ sector_average_function = lt.average_functions.Mean, \\\n+\n+ # This is the function that will be used to smooth the color ratio values\n+ # This can also be a custom function.\n+ smoothing_function = lt.smoothing.MedianBlur, \\\n+ smoothing_parameters = [3], \\\n+\n+ # Are there any platforms that use integer values for their lsc table?\n+ output_type = lt.type.Float, \\\n+\n+ # Required if and only if do_color can be or is True\n+ output_color_channels = [lt.color.R, lt.color.GR, lt.color.GB, lt.color.B], \\\n+\n+ # Required if and only if do_color can be or is False\n+ output_luminance_channels = [lt.color.GR, lt.color.GB], \\\n+\n+ # Automatically get the precision from this\n+ output_range = [0, 3.999] \\\n+\n+ # Do we need a flag to enable/disable calculating sigmas? afaik\n+ # the rkisp1 IPA doesn't use it? But we could output it anyway\n+ # and algorithms can decide whether or not if they want to use\n+ # it. Oh well, no flag for now, we can always add it later if\n+ # there's a big demand, plus it's only two to three values and\n+ # not an entire table.\n+ ))\n+tuner.setInputType(YamlParser)\n+tuner.setOutputType(YamlOutput)\n+tuner.setOutputOrder(ALSC)\n+\n+# Maybe this should be wrapped in an if __main__ = '__main__' ? That way the\n+# developer can control which tuner they want to be executed based on another\n+# layer of arguments? But I was thinking that this would handle *all* arguments\n+# based on the modules' and the input/output configurations.\n+tuner.run(sys.argv)\n", "prefixes": [ "libcamera-devel", "RFC", "RFC", "DNI" ] }