[{"id":27583,"web_url":"https://patchwork.libcamera.org/comment/27583/","msgid":"<CAHW6GYJ4206LQ5-xtafcyaEnjWPrjkFZ=5RuFvPt-q+SMsV9ew@mail.gmail.com>","date":"2023-07-18T11:52:55","subject":"Re: [libcamera-devel] [PATCH v3 07/10] libcamera: transform: Add\n\toperations with Orientation","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Jacopo\n\nThanks for these new versions. I do like them!!\n\nOn Tue, 18 Jul 2023 at 11:52, Jacopo Mondi\n<jacopo.mondi@ideasonboard.com> wrote:\n>\n> 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 the\n>   combination of the two\n>\n> These two operations allow applications to use Transforms to\n> manipulate the Orientation inside the CameraConfiguration, if they\n> wish.\n>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks\nDavid\n\n> ---\n>  include/libcamera/transform.h |  3 +++\n>  src/libcamera/transform.cpp   | 37 +++++++++++++++++++++++++++++++++++\n>  2 files changed, 40 insertions(+)\n>\n> diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h\n> index 14f1db0e8572..847a1f94713c 100644\n> --- a/include/libcamera/transform.h\n> +++ b/include/libcamera/transform.h\n> @@ -74,6 +74,9 @@ Transform transformFromRotation(int angle, bool *success = nullptr);\n>  Transform transformFromOrientation(const Orientation &orientation);\n>  Orientation transformToOrientation(const Transform &transform);\n>\n> +Transform operator/(const Orientation &o1, const Orientation &o2);\n> +Orientation operator*(const Orientation &o1, const Transform &t);\n> +\n>  const char *transformToString(Transform t);\n>\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/transform.cpp b/src/libcamera/transform.cpp\n> index d192d63d9290..80cd804ca530 100644\n> --- a/src/libcamera/transform.cpp\n> +++ b/src/libcamera/transform.cpp\n> @@ -362,6 +362,43 @@ Orientation transformToOrientation(const Transform &transform)\n>         return Orientation::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/(const Orientation &o1, const Orientation &o2)\n> +{\n> +       Transform t1 = transformFromOrientation(o1);\n> +       Transform t2 = transformFromOrientation(o2);\n> +\n> +       return -t2 * t1;\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> +Orientation operator*(const Orientation &o, const Transform &t)\n> +{\n> +       /*\n> +        * Apply a Transform corresponding to the base orientation first and\n> +        * then apply \\a t to it.\n> +        */\n> +       return transformToOrientation(transformFromOrientation(o) * t);\n> +}\n> +\n>  /**\n>   * \\brief Return a character string describing the transform\n>   * \\param[in] t The transform to be described.\n> --\n> 2.40.1\n>","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 38C29BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 18 Jul 2023 11:53:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8693D628BC;\n\tTue, 18 Jul 2023 13:53:08 +0200 (CEST)","from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com\n\t[IPv6:2607:f8b0:4864:20::22f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00E7F61E2B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jul 2023 13:53:06 +0200 (CEST)","by mail-oi1-x22f.google.com with SMTP id\n\t5614622812f47-3a38953c928so3956345b6e.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Jul 2023 04:53:06 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1689681188;\n\tbh=nJ/BZKCeAN47ST9WjaTwpQJBFHOV8udJBvXAPh60Gyk=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Jq6E8wnRj4r1DoJvo2CSGOhzcK/huu+EEbG37WMHr4bmaUAuGaEld+g/95D+B6NtK\n\t63+453vhp4oZ+htzd1zKaRZmRL86TblyD96pN0niAZEFa9A2Bo71QkFoHS3Vb3drSz\n\tu8+TgNNf9z77mCRF5KKS5QBSmPugVrfmWimMzpD3H+js1oxnC0leo5AlC3fXt1574S\n\tT3XzBF9SUMu3af2OSHiNSLW1KZ7kqIp7d/DClKOU4VhCKOmKcd0T06Odhoq+HKbDpF\n\tJpDG1tG9za7Y9O4HbToJljIRi8GYL59snAfE/pa7CMF1LeiL7iJTSQ7uxMmI6Fg16y\n\tsufh8ZPBYJ7Pg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1689681186; x=1692273186;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=Yzy6f7eY2t+WqkeN5Hjeiy0WlzqOaoRj7+ZobduUCyA=;\n\tb=KEDDE2ocUBRa5q3QHQxbUSFMha7ZC7HYv04dyNtK2XAaC7gFih+p5cL7Xhl9Qbb3mq\n\t/Bi0VNmKTbUTkeJ6iruRAhelFMX7zxDPm9HmnqC+iH+mZ+4F3W4qyNVgrXBPf2/nZZWs\n\tBPTEiq0+P4Ata8UBnHAWih0hPMUPH3UsbFfooYX2NjFDjxGtnTkcrwZEHABEJu5dPGli\n\t5cWCbuswYzB9/VhIXLSNNi2x/wCtEGpjVRHr6bErkZHDrat63U1dd5uMtFifzrtKQpe1\n\t+bfsSqXuw73cDmV55qnmWJkxKB8JQrJvN/ovr8wjEnXaNYUxYy3AzedZ4fMSWWAjg7IH\n\tklMQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"KEDDE2oc\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1689681186; x=1692273186;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=Yzy6f7eY2t+WqkeN5Hjeiy0WlzqOaoRj7+ZobduUCyA=;\n\tb=bljx9tTz7G8SPytahmwGEs633ig6pc3edXnu5pQTNNVQ7Dg+AeXWBOoY4bSZ28vNq/\n\t0VUqhKUknpjX7oHjjz5+6eGn4onmMmGi1bCaqxGRxyMpRyG4cfiVmA/bGVcK/HDi4iWj\n\t3cbUQ9GBPC92EyTEIOUgEZ1kgGV3jD3HkoUz6TxpptX3odDsocl76RiAStzDT8u8Pnqj\n\tlCERzLd5OpllEiP3Lb51hhRz35zKa7dNdpW+2MjGKTwlvUSgU6XgsRrmN9ao5pC78Wqe\n\ta+NV+oRZ1WZjG3fKGsCV9jj23WTT5MzKYZtbPlSpwydFKiI+mt/jEW96a2tvg6rZOV0c\n\tJsmw==","X-Gm-Message-State":"ABy/qLZtmbdL/Xk5nhFbw631rZ+RmBLnBPYc0wtDUQaxrYdejgVgEjM0\n\tyk+8cKB/2nTX3Gz1OUGdfgznZridR8otN3vGkVDY1Q==","X-Google-Smtp-Source":"APBJJlEMpD3G0lk9GkpuUp4//KEIx/4rkhQT6hPwmz8fjpw2egMxeFFs+LORmPGRp9HQgCXc4X2QAz95gwc7YyUUpVE=","X-Received":"by 2002:a05:6808:d4d:b0:3a3:fd7d:1e33 with SMTP id\n\tw13-20020a0568080d4d00b003a3fd7d1e33mr17037067oik.53.1689681185783;\n\tTue, 18 Jul 2023 04:53:05 -0700 (PDT)","MIME-Version":"1.0","References":"<20230718105210.83558-1-jacopo.mondi@ideasonboard.com>\n\t<20230718105210.83558-8-jacopo.mondi@ideasonboard.com>","In-Reply-To":"<20230718105210.83558-8-jacopo.mondi@ideasonboard.com>","Date":"Tue, 18 Jul 2023 12:52:55 +0100","Message-ID":"<CAHW6GYJ4206LQ5-xtafcyaEnjWPrjkFZ=5RuFvPt-q+SMsV9ew@mail.gmail.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 07/10] 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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]