Patch Detail
Show a patch.
GET /api/1.1/patches/22025/?format=api
{ "id": 22025, "url": "https://patchwork.libcamera.org/api/1.1/patches/22025/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22025/", "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": "<20241120085753.1993436-4-stefan.klug@ideasonboard.com>", "date": "2024-11-20T08:57:42", "name": "[3/7] libcamera: geometry: Add Rectangle::mappedBetween()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "94fbc330e50af8f127a19504b444d8ef58e1f71c", "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/22025/mbox/", "series": [ { "id": 4807, "url": "https://patchwork.libcamera.org/api/1.1/series/4807/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4807", "date": "2024-11-20T08:57:39", "name": "rkisp1: Fix aspect ratio and ScalerCrop", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4807/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22025/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22025/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 B1D6AC330B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Nov 2024 08:58:09 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2212165F49;\n\tWed, 20 Nov 2024 09:58:09 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD93A65F3E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Nov 2024 09:58:06 +0100 (CET)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:bbd:82cc:f3f3:e12e])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D31F2928;\n\tWed, 20 Nov 2024 09:57:48 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ugdSNCjD\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1732093068;\n\tbh=ZvuOzT6tTsES0CuCVFv8GhwTaFIPAZiE0r28BpY439I=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ugdSNCjDg06SVNuSJt8ddyRH4qAahxC7tZSLBpw28/cI2Sp3kxpmbJAKEMAEZcbWR\n\twPWbD8mu14Mi1ljyepSX+C+P+ex17BtTPsVC/UHDUloPqAZq5gYpIqvawfEHxJvWQ1\n\tgpmranSEETDb4EXg6W4FVebdJnlojNovaeMTdQ3U=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH 3/7] libcamera: geometry: Add Rectangle::mappedBetween()", "Date": "Wed, 20 Nov 2024 09:57:42 +0100", "Message-ID": "<20241120085753.1993436-4-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20241120085753.1993436-1-stefan.klug@ideasonboard.com>", "References": "<20241120085753.1993436-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": "Handling cropping and scaling within a complicated pipeline involves\ntransformations of rectangles between different coordinate systems. For\nexample the full input of the dewarper (0,0)/1920x1080 might correspond\nto the rectangle (0, 243)/2592x1458 in sensor coordinates (of a\n2592x1944 sensor). Add a function that allows the transformation of a\nrectangle defined in one reference frame (dewarper) into the coordinates\nof a second reference frame (sensor).\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n include/libcamera/geometry.h | 2 ++\n src/libcamera/geometry.cpp | 33 +++++++++++++++++++++++++++++++++\n 2 files changed, 35 insertions(+)", "diff": "diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 9ca5865a3d0d..8c5f34f4dec1 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -299,6 +299,8 @@ public:\n \t__nodiscard Rectangle scaledBy(const Size &numerator,\n \t\t\t\t const Size &denominator) const;\n \t__nodiscard Rectangle translatedBy(const Point &point) const;\n+\n+\tRectangle mappedBetween(const Rectangle &source, const Rectangle &target) const;\n };\n \n bool operator==(const Rectangle &lhs, const Rectangle &rhs);\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 90ccf8c19f97..7e29fe35801e 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -837,6 +837,39 @@ Rectangle Rectangle::translatedBy(const Point &point) const\n \treturn { x + point.x, y + point.y, width, height };\n }\n \n+/**\n+ * \\brief Maps a Rectangle from one reference frame to another\n+ * \\param[in] source The source reference frame\n+ * \\param[in] destination The destination reference frame\n+ *\n+ * The params source and destinations specify two reference frames for the same\n+ * data. The rectangle is translated from the source reference frame into the\n+ * destination reference frame.\n+ *\n+ * For example, consider a sensor with a resolution of 2592x1458 pixels and a\n+ * assume a rectangle of (0, 243)/2592x1458 (sensorFrame) in sensor coordinates\n+ * is mapped to a rectangle (0,0)/(1920,1080) (displayFrame) in display\n+ * coordinates. This function can be used to transform an arbitrary rectangle\n+ * from display coordinates to sensor coordinates or vice versa:\n+ *\n+ * \\code{.cpp}\n+ * displayRect = sensorRect.mappedBetween(sensorFrame, displayFrame);\n+ * \\endcode\n+ */\n+Rectangle Rectangle::mappedBetween(const Rectangle &source,\n+\t\t\t\t const Rectangle &destination) const\n+{\n+\tRectangle r;\n+\tdouble sx = static_cast<double>(destination.width) / source.width;\n+\tdouble sy = static_cast<double>(destination.height) / source.height;\n+\n+\tr.x = static_cast<int>((x - source.x) * sx) + destination.x;\n+\tr.y = static_cast<int>((y - source.y) * sy) + destination.y;\n+\tr.width = static_cast<int>(width * sx);\n+\tr.height = static_cast<int>(height * sy);\n+\treturn r;\n+}\n+\n /**\n * \\brief Compare rectangles for equality\n * \\return True if the two rectangles are equal, false otherwise\n", "prefixes": [ "3/7" ] }