Patch Detail
Show a patch.
GET /api/1.1/patches/21016/?format=api
{ "id": 21016, "url": "https://patchwork.libcamera.org/api/1.1/patches/21016/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21016/", "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": "<20240826152224.362773-7-stefan.klug@ideasonboard.com>", "date": "2024-08-26T15:22:04", "name": "[v1,6/8] ipa: libipa: Add lsc polynomial class", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "9f3eb2415c2045a7b2a8d524892d1fd43b4af0d4", "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/21016/mbox/", "series": [ { "id": 4540, "url": "https://patchwork.libcamera.org/api/1.1/series/4540/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4540", "date": "2024-08-26T15:21:58", "name": "Implement polynomial lsc loader", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4540/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21016/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21016/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 D3507C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Aug 2024 15:22:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 63F466341D;\n\tMon, 26 Aug 2024 17:22:47 +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 85B99633D4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Aug 2024 17:22:45 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:58b7:f3d:c9d4:defa])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4207E741;\n\tMon, 26 Aug 2024 17:21:39 +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=\"cPRy9pvF\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1724685699;\n\tbh=AOKaijGCWZOCM1rIBzUsWumA2GsBFuu9vxGIx69KhO4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=cPRy9pvFnplQg1JUkkde5YK5iWoSmmDqB5K/+2moJ4rKEJA1BP4g7C9ssVyY1iDjs\n\t7SJ7lJCGfiZ0FiiIDlYphjmE6YQF1wu2x5rHt9HL6kBaly3ECOshebjSECjduCTnQ6\n\tC29QhI3vfcnTmwQe4Qp6WRH3ecGJ7GO2c6iLPvOE=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v1 6/8] ipa: libipa: Add lsc polynomial class", "Date": "Mon, 26 Aug 2024 17:22:04 +0200", "Message-ID": "<20240826152224.362773-7-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240826152224.362773-1-stefan.klug@ideasonboard.com>", "References": "<20240826152224.362773-1-stefan.klug@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "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": "Add a basic class to represent polynomials as specified in the DNG spec for\nvignetting correction.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/meson.build | 2 +\n src/ipa/libipa/polynomial.cpp | 23 ++++++++\n src/ipa/libipa/polynomial.h | 107 ++++++++++++++++++++++++++++++++++\n 3 files changed, 132 insertions(+)\n create mode 100644 src/ipa/libipa/polynomial.cpp\n create mode 100644 src/ipa/libipa/polynomial.h", "diff": "diff --git a/src/ipa/libipa/meson.build b/src/ipa/libipa/meson.build\nindex 3740178b2909..8b085750807a 100644\n--- a/src/ipa/libipa/meson.build\n+++ b/src/ipa/libipa/meson.build\n@@ -10,6 +10,7 @@ libipa_headers = files([\n 'interpolator.h',\n 'matrix.h',\n 'module.h',\n+ 'polynomial.h',\n 'pwl.h',\n 'vector.h',\n ])\n@@ -24,6 +25,7 @@ libipa_sources = files([\n 'interpolator.cpp',\n 'matrix.cpp',\n 'module.cpp',\n+ 'polynomial.cpp',\n 'pwl.cpp',\n 'vector.cpp',\n ])\ndiff --git a/src/ipa/libipa/polynomial.cpp b/src/ipa/libipa/polynomial.cpp\nnew file mode 100644\nindex 000000000000..39b17b29314b\n--- /dev/null\n+++ b/src/ipa/libipa/polynomial.cpp\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas On Board\n+ *\n+ * Polynomal class to represent lens shading correction\n+ */\n+\n+#include \"polynomial.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+/**\n+ * \\file polynomial.h\n+ * \\brief Polynomial class\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Polynomial)\n+\n+namespace ipa {\n+}\n+} // namespace libcamera\ndiff --git a/src/ipa/libipa/polynomial.h b/src/ipa/libipa/polynomial.h\nnew file mode 100644\nindex 000000000000..971be062297f\n--- /dev/null\n+++ b/src/ipa/libipa/polynomial.h\n@@ -0,0 +1,107 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2024, Ideas On Board\n+ *\n+ * Vector and related operations\n+ */\n+#pragma once\n+\n+#include <algorithm>\n+#include <array>\n+#include <assert.h>\n+#include <cmath>\n+\n+#include <libcamera/base/log.h>\n+#include <libcamera/base/span.h>\n+\n+#include \"libcamera/internal/yaml_parser.h\"\n+\n+namespace libcamera {\n+\n+LOG_DECLARE_CATEGORY(Polynomial)\n+\n+namespace ipa {\n+\n+constexpr int kNumCoefficients = 5;\n+class Polynomial\n+{\n+public:\n+\t/**\n+\t * Note: cx and cy are relative to the image size\n+\t */\n+\tPolynomial(double cx = 0.0, double cy = 0.0, double k0 = 0.0,\n+\t\t double k1 = 0.0, double k2 = 0.0, double k3 = 0.0,\n+\t\t double k4 = 0.0)\n+\t\t: cx_(cx), cy_(cy),\n+\t\t coefficients_({ k0, k1, k2, k3, k4 })\n+\t{\n+\t}\n+\n+\tdouble sampleAtNormalizedPixelPos(double x, double y) const\n+\t{\n+\t\tdouble dx = x - cnx_;\n+\t\tdouble dy = y - cny_;\n+\t\tdouble r = sqrt(dx * dx + dy * dy);\n+\t\tdouble res = 1.0;\n+\t\tfor (int i = 0; i < kNumCoefficients; i++) {\n+\t\t\tres += coefficients_[i] * std::pow(r, (i + 1) * 2);\n+\t\t}\n+\t\treturn res;\n+\t}\n+\n+\t/**\n+ * Returns m according to dng spec. 𝑚 represents the Euclidean distance\n+\t * (in pixels) from the optical center to the farthest pixel in the\n+\t * image.\n+\t */\n+\tdouble getM() const\n+\t{\n+\t\tdouble cpx = imageSize_.width * cx_;\n+\t\tdouble cpy = imageSize_.height * cy_;\n+\t\tdouble mx = std::max(cpx, std::fabs(imageSize_.width - cpx));\n+\t\tdouble my = std::max(cpy, std::fabs(imageSize_.height - cpy));\n+\n+\t\treturn sqrt(mx * mx + my * my);\n+\t}\n+\n+\tvoid setReferenceImageSize(const Size &size)\n+\t{\n+\t\timageSize_ = size;\n+\t\t/* Calculate normalized centers */\n+\t\tdouble m = getM();\n+\t\tcnx_ = (size.width * cx_) / m;\n+\t\tcny_ = (size.height * cy_) / m;\n+\t}\n+\n+private:\n+\tdouble cx_;\n+\tdouble cy_;\n+\tdouble cnx_;\n+\tdouble cny_;\n+\tstd::array<double, kNumCoefficients> coefficients_;\n+\n+\tSize imageSize_;\n+};\n+\n+} /* namespace ipa */\n+\n+template<>\n+struct YamlObject::Getter<ipa::Polynomial> {\n+\tstd::optional<ipa::Polynomial> get(const YamlObject &obj) const\n+\t{\n+\t\tstd::optional<double> cx = obj[\"cx\"].get<double>();\n+\t\tstd::optional<double> cy = obj[\"cy\"].get<double>();\n+\t\tstd::optional<double> k0 = obj[\"k0\"].get<double>();\n+\t\tstd::optional<double> k1 = obj[\"k1\"].get<double>();\n+\t\tstd::optional<double> k2 = obj[\"k2\"].get<double>();\n+\t\tstd::optional<double> k3 = obj[\"k3\"].get<double>();\n+\t\tstd::optional<double> k4 = obj[\"k4\"].get<double>();\n+\n+\t\tif (!(cx && cy && k0 && k1 && k2 && k3 && k4))\n+\t\t\tLOG(Polynomial, Error) << \"Polynomial is missing parameter \";\n+\n+\t\treturn ipa::Polynomial(*cx, *cy, *k0, *k1, *k2, *k3, *k4);\n+\t}\n+};\n+\n+} /* namespace libcamera */\n", "prefixes": [ "v1", "6/8" ] }