Show a patch.

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

{
    "id": 27358,
    "url": "https://patchwork.libcamera.org/api/patches/27358/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/27358/",
    "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": "<20260709124159.387110-3-stefan.klug@ideasonboard.com>",
    "date": "2026-07-09T12:41:51",
    "name": "[v3,2/2] libcamera: converter: converter_dw100: Allow to transform between different camera matrices",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d56d3b375ab04a35081215fa5a3c87dd3d257840",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/27358/mbox/",
    "series": [
        {
            "id": 6054,
            "url": "https://patchwork.libcamera.org/api/series/6054/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6054",
            "date": "2026-07-09T12:41:49",
            "name": "Add cmNew to dewarp paremeters",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/6054/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/27358/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/27358/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 BAFCBBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jul 2026 12:42:13 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 669CC66101;\n\tThu,  9 Jul 2026 14:42:13 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F771660E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jul 2026 14:42:12 +0200 (CEST)",
            "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:b99c:646e:18fa:5ff])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 911F5153F;\n\tThu,  9 Jul 2026 14:41:21 +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=\"dyAVFLax\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783600881;\n\tbh=HE50nK1cOnAoYdxMfQE9JzW6tQ67uJpKtqbzbImaabI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=dyAVFLaxIK9+XBbUpobwgAg9fXB9FSbvKkewHEadVQE5m1zj/QOQfhW/aXLewvHJe\n\tPmDgi0dsZo6SxaJvi/VEOtwm3ysliYP+2tRPrcs3G42wXLzgWM4WZ88GoH1ZwrU9po\n\tEZBKdIx4gGGojwrOOvMhBdHIenyG5vo52xd9/gX8=",
        "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>,\n\tPaul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v3 2/2] libcamera: converter: converter_dw100: Allow to\n\ttransform between different camera matrices",
        "Date": "Thu,  9 Jul 2026 14:41:51 +0200",
        "Message-ID": "<20260709124159.387110-3-stefan.klug@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260709124159.387110-1-stefan.klug@ideasonboard.com>",
        "References": "<20260709124159.387110-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": "To configure the lens dewarping, the calibrated camera matrix and the\ndistortion coefficients are required. For some use cases (like removing\na skew introduced by the camera geometry) it is necessary to define an\nadditional output camera matrix often called \"new camera matrix\". Add\nthat functionality by adding an optional tuning parameter \"cmNew\" to the\nDewarp configuration. If that parameter is not provided, cm is used\ninstead.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\n\nChanges in v3:\n- Improved commit message\n- Collected tags\n- Fixed code wrapping\n\nChanges in v0.2:\n- Swapped cm and cmNew in the output calculation\n---\n .../converter/converter_dw100_vertexmap.h         |  2 ++\n src/libcamera/converter/converter_dw100.cpp       | 15 ++++++++++++++-\n .../converter/converter_dw100_vertexmap.cpp       |  8 ++++++--\n 3 files changed, 22 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/converter/converter_dw100_vertexmap.h b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\nindex 1f2f9c88e8e8..8cb86ed546f6 100644\n--- a/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n+++ b/include/libcamera/internal/converter/converter_dw100_vertexmap.h\n@@ -34,6 +34,7 @@ public:\n \tstruct DewarpParams {\n \t\tDewarpParams()\n \t\t\t: cm(Matrix<double, 3, 3>::identity()),\n+\t\t\t  cmNew(Matrix<double, 3, 3>::identity()),\n \t\t\t  coefficients({})\n \t\t{\n \t\t}\n@@ -41,6 +42,7 @@ public:\n \t\tint setCoefficients(Span<const double> coeffs);\n \n \t\tMatrix<double, 3, 3> cm;\n+\t\tMatrix<double, 3, 3> cmNew;\n \n \t\tstruct {\n \t\t\tdouble k1;\ndiff --git a/src/libcamera/converter/converter_dw100.cpp b/src/libcamera/converter/converter_dw100.cpp\nindex d05823fa4d4c..77f778c7f103 100644\n--- a/src/libcamera/converter/converter_dw100.cpp\n+++ b/src/libcamera/converter/converter_dw100.cpp\n@@ -104,9 +104,10 @@ int ConverterDW100Module::init(const ValueNode &params)\n \n \tauto &cm = params[\"cm\"];\n \tauto &coefficients = params[\"coefficients\"];\n+\tauto &cmNew = params[\"cmNew\"];\n \n \t/* If nothing is provided, the dewarper is still functional */\n-\tif (!cm && !coefficients)\n+\tif (!cm && !coefficients && !cmNew)\n \t\treturn 0;\n \n \tif (!cm) {\n@@ -140,6 +141,18 @@ int ConverterDW100Module::init(const ValueNode &params)\n \t\treturn -EINVAL;\n \t}\n \n+\tif (cmNew) {\n+\t\tmatrix = cmNew.get<Matrix<double, 3, 3>>();\n+\t\tif (!matrix) {\n+\t\t\tLOG(Converter, Error) << \"Failed to load 'cmNew' value\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tdp.cmNew = *matrix;\n+\t} else {\n+\t\tdp.cmNew = dp.cm;\n+\t}\n+\n \tdewarpParams_ = dp;\n \n \treturn 0;\ndiff --git a/src/libcamera/converter/converter_dw100_vertexmap.cpp b/src/libcamera/converter/converter_dw100_vertexmap.cpp\nindex a990ab4952b4..d5fbfdaafde2 100644\n--- a/src/libcamera/converter/converter_dw100_vertexmap.cpp\n+++ b/src/libcamera/converter/converter_dw100_vertexmap.cpp\n@@ -234,6 +234,9 @@ int dw100VerticesForLength(const int length)\n  * \\var Dw100VertexMap::DewarpParams::cm\n  * \\brief The camera matrix\n  *\n+ * \\var Dw100VertexMap::DewarpParams::cmNew\n+ * \\brief The new camera matrix after dewarping\n+ *\n  * \\var Dw100VertexMap::DewarpParams::coefficients\n  * \\brief Structure containing the lens dewarp coefficients\n \n@@ -665,10 +668,11 @@ Vector2d Dw100VertexMap::dewarpPoint(const Vector2d &p)\n \tdouble x, y;\n \tdouble xout, yout;\n \tauto &cm = dewarpParams_->cm;\n+\tauto &cmNew = dewarpParams_->cmNew;\n \tauto &c = dewarpParams_->coefficients;\n \n-\ty = (p.y() - cm[1][2]) / cm[1][1];\n-\tx = (p.x() - cm[0][2] - y * cm[0][1]) / cm[0][0];\n+\ty = (p.y() - cmNew[1][2]) / cmNew[1][1];\n+\tx = (p.x() - cmNew[0][2] - y * cmNew[0][1]) / cmNew[0][0];\n \n \tdouble r2 = x * x + y * y;\n \tdouble r4 = r2 * r2;\n",
    "prefixes": [
        "v3",
        "2/2"
    ]
}