Patch Detail
Show a patch.
GET /api/1.1/patches/18828/?format=api
{ "id": 18828, "url": "https://patchwork.libcamera.org/api/1.1/patches/18828/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18828/", "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": "<20230714141549.11085-7-jacopo.mondi@ideasonboard.com>", "date": "2023-07-14T14:15:46", "name": "[libcamera-devel,v2,6/9] libcamera: transform: Add operations with Orientation", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d83156c8dd6cd46a59b0608ae124695998e307a7", "submitter": { "id": 143, "url": "https://patchwork.libcamera.org/api/1.1/people/143/?format=api", "name": "Jacopo Mondi", "email": "jacopo.mondi@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18828/mbox/", "series": [ { "id": 3971, "url": "https://patchwork.libcamera.org/api/1.1/series/3971/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3971", "date": "2023-07-14T14:15:40", "name": "libcamera: Replace CameraConfiguration::transform", "version": 2, "mbox": "https://patchwork.libcamera.org/series/3971/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18828/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18828/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 54AAEC32AB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Jul 2023 14:16:15 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2346628D7;\n\tFri, 14 Jul 2023 16:16:14 +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 8A951628CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Jul 2023 16:16:12 +0200 (CEST)", "from uno.localdomain (mob-5-90-9-92.net.vodafone.it [5.90.9.92])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3EECD7F3;\n\tFri, 14 Jul 2023 16:15:21 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689344174;\n\tbh=21h9/sAEYM75LWopORzoBDULCTVzIfbDSYtOMTm5ysY=;\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:Cc:\n\tFrom;\n\tb=Ssn7BKAqUYW8aA5CXiQ2tWmcnpbVSybhGMDahJRVlG66C99zxjM9W1Ht8SRAyObVN\n\tyYOzJ9L7fPwtM+NWnTch5cVcFVIDgmhppWFJiSLMfSb7d39N/Q+PuKi+8lVIH5r4iH\n\t2/2DdsOjFGA+xkg6Gw5+nrc/N1qpkJr4+zCCDiLkhgBtlnwgHlf1hgiSGrlDetRAFy\n\tKInAwzF65ABeIEFTzl5EWiiyOnuBpEkC6myh4BXwCkHzdRXhczqOWgv+ZtfBA0yCub\n\tIPlNY1CfoKpqw2rHz8tU6WBQKfuxbqn4pLpsjiFbX8qpEZclUrmAcuV/OUexDlzaqt\n\tGJIz1cuRcZb0Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1689344121;\n\tbh=21h9/sAEYM75LWopORzoBDULCTVzIfbDSYtOMTm5ysY=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=fpAwlQBcf6CxBBbnxLDtn9NuwyWo11K5vudSW1mGQ4RrK/Ml6bj6t1AWIVYD0iM53\n\tnXExyZM9pgcq4llhuf+aPv4140klM00D6uRpUB2lxOkwGgRROtDHusQiBgqEE/gfzY\n\tHwiLoFF9miZQXuRjVwj2cIEssp2xPVCyDlnkCPlE=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fpAwlQBc\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 14 Jul 2023 16:15:46 +0200", "Message-Id": "<20230714141549.11085-7-jacopo.mondi@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "In-Reply-To": "<20230714141549.11085-1-jacopo.mondi@ideasonboard.com>", "References": "<20230714141549.11085-1-jacopo.mondi@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 6/9] libcamera: transform: Add\n\toperations with Orientation", "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": "Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add two operations that allows to combine Transform with Orientation.\n\n- Transform operator/(Orientation1, Orientation2)\n allows to easily get back the Transform that needs to be applied to\n Orientation2 to get Orientation1\n\n- Orientation operator*(Orientation1, Transform)\n allows to apply a Transform to an Orientation and obtain back the\n combination of the two\n\nThe two operations allow application that are willing to use Transform\nto operate with the Orientation part of CameraConfiguration.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/transform.h | 5 ++\n src/libcamera/transform.cpp | 98 +++++++++++++++++++++++++++++++++++\n 2 files changed, 103 insertions(+)", "diff": "diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h\nindex 573adf18715d..a7470c70a755 100644\n--- a/include/libcamera/transform.h\n+++ b/include/libcamera/transform.h\n@@ -74,6 +74,11 @@ Transform transformFromRotation(int angle, bool *success = nullptr);\n Transform transformFromOrientation(const CameraConfiguration::Orientation &orientation);\n CameraConfiguration::Orientation transformToOrientation(const Transform &transform);\n \n+Transform operator/(CameraConfiguration::Orientation o1,\n+\t\t CameraConfiguration::Orientation o2);\n+CameraConfiguration::Orientation operator*(CameraConfiguration::Orientation o1,\n+\t\t\t\t\t Transform t);\n+\n const char *transformToString(Transform t);\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/transform.cpp b/src/libcamera/transform.cpp\nindex 03d2b52e7f38..61dbb1ff1dd5 100644\n--- a/src/libcamera/transform.cpp\n+++ b/src/libcamera/transform.cpp\n@@ -357,6 +357,104 @@ CameraConfiguration::Orientation transformToOrientation(const Transform &transfo\n \treturn CameraConfiguration::rotate0;\n }\n \n+/**\n+ * \\brief Return the Transform that applied to \\a o2 gives \\a o1\n+ * \\param o1 The Orientation to obtain\n+ * \\param o2 The base Orientation\n+ *\n+ * This operation can be used to easily compute the Transform to apply to a\n+ * base orientation \\a o2 to get the desired orientation \\a o1.\n+ *\n+ * The CameraSensor class uses this function to compute what Transform to apply\n+ * to a camera with mounting rotation \\a o2 (the base) to obtain the user\n+ * requested orientation \\a o1.\n+ *\n+ * \\return A Transform that applied to \\a o2 gives \\a o1\n+ */\n+Transform operator/(CameraConfiguration::Orientation o1,\n+\t\t CameraConfiguration::Orientation o2)\n+{\n+\tTransform t1 = transformFromOrientation(o1);\n+\tTransform t2 = transformFromOrientation(o2);\n+\n+\t/* Return immediately if the two are identical. */\n+\tif (t1 == t2)\n+\t\treturn Transform::Identity;\n+\n+\t/* If t1 is identity we need to apply -t2 to get it. */\n+\tif (t1 == Transform::Identity)\n+\t\treturn -t2;\n+\n+\t/* If t2 is identity, to get t1 we still need to do... t1. */\n+\tif (t2 == Transform::Identity)\n+\t\treturn t1;\n+\n+\tTransform combined = t1 ^ t2;\n+\tTransform result = combined;\n+\n+\t/*\n+\t * If the base orientation is transposed we need to invert the flips on\n+\t * the combined result.\n+\t *\n+\t * Using Rot90 as an example:\n+\t *\n+\t * Rot180 / Rot90 = Rot90\n+\t * = (H|V) ^ (T|V) = (T|H)\n+\t * = invert_flips(T|H) = (T|V) = Rot90\n+\t *\n+\t * Rot0 / Rot90 = Rot270\n+\t * = () ^ (T|V) = (T|V)\n+\t * = invert_flips(T|V) = (T|H) = Rot270\n+\t *\n+\t * Rot270 / Rot90 = Rot180\n+\t * = (T|H) ^ (T|V) = (H|V)\n+\t * = invert_flips(H|V) = (V|H) = Rot180\n+\t *\n+\t * Rot180Transpose / Rot90 = V\n+\t * = (T|H|V) ^ (T|V) = (H)\n+\t * = invert_flips(H) = (V)\n+\t *\n+\t * Rot270 / Transpose = V\n+\t * = (T|H) ^ T = H\n+\t * = invert_flips(H) = (V)\n+\t */\n+\tif (!!(t2 & Transform::Transpose)) {\n+\t\tresult = combined & Transform::Transpose;\n+\t\tif (!!(combined & Transform::HFlip))\n+\t\t\tresult |= Transform::VFlip;\n+\t\tif (!!(combined & Transform::VFlip))\n+\t\t\tresult |= Transform::HFlip;\n+\t}\n+\n+\treturn result;\n+}\n+\n+/**\n+ * \\brief Apply the Transform \\a t on the base orientation \\a o\n+ * \\param o The base orientation\n+ * \\param t The transform to apply on \\a o\n+ * \\return The Orientation resulting from applying \\a t on \\a o\n+ */\n+CameraConfiguration::Orientation operator*(CameraConfiguration::Orientation o,\n+\t\t\t\t\t Transform t)\n+{\n+\t/* Apply an Indentity always gives us back the other operand. */\n+\tif (t == Transform::Identity)\n+\t\treturn o;\n+\n+\t/*\n+\t * As operator*(Transform t2, Transform t1) composes two Tranform\n+\t * by applying t1 first then t2 according to the canonical function\n+\t * composition notion, we here first apply a Transform corresponding to\n+\t * the base orientation and the apply \\a t to it.\n+\t */\n+\tTransform t1 = transformFromOrientation(o);\n+\tif (t1 == Transform::Identity)\n+\t\treturn transformToOrientation(t);\n+\n+\treturn transformToOrientation(t * t1);\n+}\n+\n /**\n * \\brief Return a character string describing the transform\n * \\param[in] t The transform to be described.\n", "prefixes": [ "libcamera-devel", "v2", "6/9" ] }