[{"id":31483,"web_url":"https://patchwork.libcamera.org/comment/31483/","msgid":"<CAEB1ahtJ1ApsoMg_xnRqqi18iu2S7r8hR9f5joRvAhqkgjE2Bw@mail.gmail.com>","date":"2024-10-01T07:19:33","subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"content":"Hi Jacopo,\n\nThanks for the updated description.\nIt makes more sense to me.\n\nReviewed-by: Harvey Yang <chenghaoyang@chromium.org>\n\nBR,\nHarvey\n\nOn Tue, Oct 1, 2024 at 3:59 AM Jacopo Mondi\n<jacopo.mondi@ideasonboard.com> wrote:\n>\n> The libcamera::Rectangle class allows defining rectangles regardless of\n> the orientation of the reference system where a rectangle is used in.\n>\n> This implies that, depending on the reference system in use, the\n> rectangle's top-left corner, as defined by libcamera, doesn't correspond\n> to the visual top-left position.\n>\n>          ^\n>          |\n>          |      -------------------\n>          |      ^                 | h\n>          |      |                 |\n>         y|      o---->-------------\n>          |               w\n>           ------------------------------->\n>          (0,0)  x\n>\n>          (0,0)  x\n>            ------------------------------>\n>           |              w\n>          y|     o---->-------------\n>           |     |                 | h\n>           |     v                 |\n>           |     -------------------\n>           |\n>           V\n>\n> Clarify that a Rectangle's top-left corner corresponds to the point\n> with the smaller x and y coordinates and that the horizontal and\n> vertical dimensions are obtained by positive increments along the\n> corresponding axes.\n>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> ---\n>  src/libcamera/geometry.cpp | 93 ++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 93 insertions(+)\n>\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 000151364c7f..6eb432e5d803 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -595,6 +595,88 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * Rectangles are used to identify an area of an image. They are specified by\n>   * the coordinates of top-left corner and their horizontal and vertical size.\n>   *\n> + * libcamera canonically defines a rectangle's 'top-left' corner as the point\n> + * with the smaller 'x' and smaller 'y' coordinates. Depending on the reference\n> + * system where the rectangle is used this might not correspond to the visual\n> + * top-left corner of the rectangle.\n> + *\n> + * The rectangle's horizontal and vertical dimensions are obtained by positively\n> + * increments along the corresponding axes by the given horizontal and vertical\n> + * sizes.\n> + *\n> + * Examples:\n> + *\n> + * \\verbatim\n> +\n> +  X = top-left corner\n> +  o = reference system origin point\n> +\n> +          ^\n> +          |\n> +          |      -----------------\n> +          |     ^                 |\n> +          |     |                 |\n> +          |     X--->-------------\n> +          |\n> +          o------------------------------->\n> +         (0,0)\n> +\n> +\n> +                                      (0,0)\n> +          <-------------------------------o\n> +                                          |\n> +                 -------------<---X       |\n> +                |                 |       |\n> +                |                 V       |\n> +                 -----------------        |\n> +                                          V\n> +\n> +\n> +         (0,0)\n> +          o------------------------------->\n> +          |     X--->-------------\n> +          |     |                 |\n> +          |     v                 |\n> +          |      -----------------\n> +          |\n> +          V\n> +\n> +                                          ^\n> +                                          |\n> +                 -----------------        |\n> +                |                 ^       |\n> +                |                 |       |\n> +                 -------------<---X       |\n> +          <-------------------------------o\n> +                                      (0,0)\n> +\n> +                         ^\n> +                         |\n> +                   ------|-----------\n> +                  ^      |           |\n> +                  |      |           |\n> +                  X--->--|-----------\n> +          ---------------o---------------->\n> +                         |(0,0)\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +\n> +                         ^\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +          ---------------o---------------->\n> +                    (0,0)|   ------------\n> +                         |  ^            |\n> +                         |  |            |\n> +                         |  X--->--------\n> +                         |\n> +   \\endverbatim\n> + *\n>   * The measure unit of the rectangle coordinates and size, as well as the\n>   * reference point from which the Rectangle::x and Rectangle::y displacements\n>   * refers to, are defined by the context were rectangle is used.\n> @@ -611,6 +693,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * \\param[in] x The horizontal coordinate of the top-left corner\n>   * \\param[in] y The vertical coordinate of the top-left corner\n>   * \\param[in] size The size\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>\n>  /**\n> @@ -620,6 +704,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * \\param[in] y The vertical coordinate of the top-left corner\n>   * \\param[in] width The width\n>   * \\param[in] height The height\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>\n>  /**\n> @@ -632,11 +718,15 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>  /**\n>   * \\var Rectangle::x\n>   * \\brief The horizontal coordinate of the rectangle's top-left corner\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>\n>  /**\n>   * \\var Rectangle::y\n>   * \\brief The vertical coordinate of the rectangle's top-left corner\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>\n>  /**\n> @@ -685,6 +775,9 @@ Point Rectangle::center() const\n>  /**\n>   * \\fn Point Rectangle::topLeft() const\n>   * \\brief Retrieve the coordinates of the top left corner of this Rectangle\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n> + *\n>   * \\return The Rectangle's top left corner\n>   */\n>\n> --\n> 2.46.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 77D13BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Oct 2024 07:19:47 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 03ED463515;\n\tTue,  1 Oct 2024 09:19:47 +0200 (CEST)","from mail-lj1-x233.google.com (mail-lj1-x233.google.com\n\t[IPv6:2a00:1450:4864:20::233])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1550460553\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2024 09:19:45 +0200 (CEST)","by mail-lj1-x233.google.com with SMTP id\n\t38308e7fff4ca-2fadb636abaso2978271fa.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 01 Oct 2024 00:19:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"ebUaiNa6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1727767184; x=1728371984;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=32i2vmXH+LIHkVBeItbzi8UleLWEs+9rle33KkKCa9s=;\n\tb=ebUaiNa6JYmJz9Uj21U+3yyF95Q8P2rl7Ky5xWJ3B/VWxrl1k0UhBXl0/29BWZj7Bb\n\tFzwcakkQgUr4NHccfv4ScqXBbjRjTIYuaEY9L0pEeQ5PL8IWZWR04Mq4i10irSc6CHDG\n\tnx6bRZfS0fADOL2G36Rr0DvSAD+Z+BkYvAiBQ=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1727767184; x=1728371984;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=32i2vmXH+LIHkVBeItbzi8UleLWEs+9rle33KkKCa9s=;\n\tb=q16edUuEolNMQrS+iYgWV/PIvfQO+xF+iWbQhVopaKahH3BjUoYqFG+JywjoMZrNt4\n\tdjXNHnnFXRXXDLbbdWVVXso915l1Q9Ho88OJwae3UMzcnJLavfqoFjnsq2weMa4/13r7\n\t3T9i6p8/nfcGmVDTeabwESnYOCXx08dx5AzeNnMyai0CJploVvS9A+KyVcFsRIm9t+jf\n\tdNogx79NeF0At+Nw6I7bwwGRohTGnAZCqRILbGfik/RGBhJhlP1Gfzbs8R0VFprxQt98\n\tg88gpBd8Pxim9X3GSH7DRt++9od1Oti2acoXleXaNd0K39GAO0VI6uGJw0UuJqiFU8R/\n\tAliw==","X-Gm-Message-State":"AOJu0Yw/sfp0tmtrbWPqz+/FMZuBs2dJySdW62fyjALPVUchSY5Xigz+\n\tqBVlv3YXPlO7LBBtLAk2VUIJwEgYKnHADPugiqVPDF+ZXRFZuA7wWth1qUeiPE8ZdcVIuAfT60e\n\tOE1Lr8UnBgXO0aJxrebtIeS/w5jKgkviLlqsmtno8cLJTZzJoSA==","X-Google-Smtp-Source":"AGHT+IGT3/62+wX+Sr1JBRXd+jsj+QeISle/FLcZ+TtkajHEuIR7npjhzZIWaAzMup08jbdqpO+uNUMXF75gjDT0L7I=","X-Received":"by 2002:a2e:750:0:b0:2f5:a29:5a42 with SMTP id\n\t38308e7fff4ca-2f9d3e5d375mr61540671fa.14.1727767184236; \n\tTue, 01 Oct 2024 00:19:44 -0700 (PDT)","MIME-Version":"1.0","References":"<20240930195915.152187-1-jacopo.mondi@ideasonboard.com>\n\t<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","In-Reply-To":"<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","From":"Cheng-Hao Yang <chenghaoyang@chromium.org>","Date":"Tue, 1 Oct 2024 15:19:33 +0800","Message-ID":"<CAEB1ahtJ1ApsoMg_xnRqqi18iu2S7r8hR9f5joRvAhqkgjE2Bw@mail.gmail.com>","Subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}},{"id":31490,"web_url":"https://patchwork.libcamera.org/comment/31490/","msgid":"<CAHW6GYKZGPSBBp8iwnzuiODnbZ1qkGvO-_tgrdTZE9SrKgHe1Q@mail.gmail.com>","date":"2024-10-01T08:18:12","subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","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 the clarification here.\n\nYes, I think this is exactly right. I think the important point is\nthat the \"top left\" is the corner with smallest x and y in the\ncoordinate system in which the rectangle was created.\n\n(A viewer might be standing, for example, upside down with respect to\nthat, in which case it's not _their_ top left any more. But it's the\nviewer's problem to deal with their own \"transform\".)\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\nOn Tue, 1 Oct 2024 at 08:19, Cheng-Hao Yang <chenghaoyang@chromium.org> wrote:\n>\n> Hi Jacopo,\n>\n> Thanks for the updated description.\n> It makes more sense to me.\n>\n> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>\n>\n> BR,\n> Harvey\n>\n> On Tue, Oct 1, 2024 at 3:59 AM Jacopo Mondi\n> <jacopo.mondi@ideasonboard.com> wrote:\n> >\n> > The libcamera::Rectangle class allows defining rectangles regardless of\n> > the orientation of the reference system where a rectangle is used in.\n> >\n> > This implies that, depending on the reference system in use, the\n> > rectangle's top-left corner, as defined by libcamera, doesn't correspond\n> > to the visual top-left position.\n> >\n> >          ^\n> >          |\n> >          |      -------------------\n> >          |      ^                 | h\n> >          |      |                 |\n> >         y|      o---->-------------\n> >          |               w\n> >           ------------------------------->\n> >          (0,0)  x\n> >\n> >          (0,0)  x\n> >            ------------------------------>\n> >           |              w\n> >          y|     o---->-------------\n> >           |     |                 | h\n> >           |     v                 |\n> >           |     -------------------\n> >           |\n> >           V\n> >\n> > Clarify that a Rectangle's top-left corner corresponds to the point\n> > with the smaller x and y coordinates and that the horizontal and\n> > vertical dimensions are obtained by positive increments along the\n> > corresponding axes.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> > ---\n> >  src/libcamera/geometry.cpp | 93 ++++++++++++++++++++++++++++++++++++++\n> >  1 file changed, 93 insertions(+)\n> >\n> > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> > index 000151364c7f..6eb432e5d803 100644\n> > --- a/src/libcamera/geometry.cpp\n> > +++ b/src/libcamera/geometry.cpp\n> > @@ -595,6 +595,88 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n> >   * Rectangles are used to identify an area of an image. They are specified by\n> >   * the coordinates of top-left corner and their horizontal and vertical size.\n> >   *\n> > + * libcamera canonically defines a rectangle's 'top-left' corner as the point\n> > + * with the smaller 'x' and smaller 'y' coordinates. Depending on the reference\n> > + * system where the rectangle is used this might not correspond to the visual\n> > + * top-left corner of the rectangle.\n> > + *\n> > + * The rectangle's horizontal and vertical dimensions are obtained by positively\n> > + * increments along the corresponding axes by the given horizontal and vertical\n> > + * sizes.\n> > + *\n> > + * Examples:\n> > + *\n> > + * \\verbatim\n> > +\n> > +  X = top-left corner\n> > +  o = reference system origin point\n> > +\n> > +          ^\n> > +          |\n> > +          |      -----------------\n> > +          |     ^                 |\n> > +          |     |                 |\n> > +          |     X--->-------------\n> > +          |\n> > +          o------------------------------->\n> > +         (0,0)\n> > +\n> > +\n> > +                                      (0,0)\n> > +          <-------------------------------o\n> > +                                          |\n> > +                 -------------<---X       |\n> > +                |                 |       |\n> > +                |                 V       |\n> > +                 -----------------        |\n> > +                                          V\n> > +\n> > +\n> > +         (0,0)\n> > +          o------------------------------->\n> > +          |     X--->-------------\n> > +          |     |                 |\n> > +          |     v                 |\n> > +          |      -----------------\n> > +          |\n> > +          V\n> > +\n> > +                                          ^\n> > +                                          |\n> > +                 -----------------        |\n> > +                |                 ^       |\n> > +                |                 |       |\n> > +                 -------------<---X       |\n> > +          <-------------------------------o\n> > +                                      (0,0)\n> > +\n> > +                         ^\n> > +                         |\n> > +                   ------|-----------\n> > +                  ^      |           |\n> > +                  |      |           |\n> > +                  X--->--|-----------\n> > +          ---------------o---------------->\n> > +                         |(0,0)\n> > +                         |\n> > +                         |\n> > +                         |\n> > +                         |\n> > +\n> > +                         ^\n> > +                         |\n> > +                         |\n> > +                         |\n> > +                         |\n> > +                         |\n> > +          ---------------o---------------->\n> > +                    (0,0)|   ------------\n> > +                         |  ^            |\n> > +                         |  |            |\n> > +                         |  X--->--------\n> > +                         |\n> > +   \\endverbatim\n> > + *\n> >   * The measure unit of the rectangle coordinates and size, as well as the\n> >   * reference point from which the Rectangle::x and Rectangle::y displacements\n> >   * refers to, are defined by the context were rectangle is used.\n> > @@ -611,6 +693,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n> >   * \\param[in] x The horizontal coordinate of the top-left corner\n> >   * \\param[in] y The vertical coordinate of the top-left corner\n> >   * \\param[in] size The size\n> > + *\n> > + * The rectangle's top-left corner is the point with the smaller x and y values.\n> >   */\n> >\n> >  /**\n> > @@ -620,6 +704,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n> >   * \\param[in] y The vertical coordinate of the top-left corner\n> >   * \\param[in] width The width\n> >   * \\param[in] height The height\n> > + *\n> > + * The rectangle's top-left corner is the point with the smaller x and y values.\n> >   */\n> >\n> >  /**\n> > @@ -632,11 +718,15 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n> >  /**\n> >   * \\var Rectangle::x\n> >   * \\brief The horizontal coordinate of the rectangle's top-left corner\n> > + *\n> > + * The rectangle's top-left corner is the point with the smaller x and y values.\n> >   */\n> >\n> >  /**\n> >   * \\var Rectangle::y\n> >   * \\brief The vertical coordinate of the rectangle's top-left corner\n> > + *\n> > + * The rectangle's top-left corner is the point with the smaller x and y values.\n> >   */\n> >\n> >  /**\n> > @@ -685,6 +775,9 @@ Point Rectangle::center() const\n> >  /**\n> >   * \\fn Point Rectangle::topLeft() const\n> >   * \\brief Retrieve the coordinates of the top left corner of this Rectangle\n> > + *\n> > + * The rectangle's top-left corner is the point with the smaller x and y values.\n> > + *\n> >   * \\return The Rectangle's top left corner\n> >   */\n> >\n> > --\n> > 2.46.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 5CBE4C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Oct 2024 08:18:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 05FC06350E;\n\tTue,  1 Oct 2024 10:18:26 +0200 (CEST)","from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com\n\t[IPv6:2607:f8b0:4864:20::72e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 430A760553\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2024 10:18:24 +0200 (CEST)","by mail-qk1-x72e.google.com with SMTP id\n\taf79cd13be357-7a99fde9f1dso467217085a.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 01 Oct 2024 01:18:24 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"k1J7AkEi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1727770703; x=1728375503;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=DZMfTwry5WFtHIgsMjC6JQIjW0sduVMup9VjEEXCboQ=;\n\tb=k1J7AkEiowuZBG44TjTCdokcfOeJyoQGDZQ9eXQ23hILSwJsFernTc4zztJrvsI/Do\n\tCcL8JwXVIs0yLOeW66vutFDxo7/QeQSjWPgIGypZnUUtxQC5qJSFlxoIOpLF8V1tCloj\n\tJgwR/5sHg1mlp/TX3+Y/pROntPlnwjYdGhBKk0QLBuFCQv6IrHUJ5rXxpTM89M8UaZ1G\n\thg79GDDc3YJay3EpxItw1V5cnsOnON3wYaX54yq2HxvYWQ4jq925ANoj4kGPDL/xTz4t\n\tEGvpQ8f9tOYL49O13GGdjC2HLrfSWIQ7CsqOSGg9edEwm8QXbHnnWZb2ZLYDFaHJMcO5\n\ta+Fg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1727770703; x=1728375503;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=DZMfTwry5WFtHIgsMjC6JQIjW0sduVMup9VjEEXCboQ=;\n\tb=Cd3+k6wfcPrIv7m8YKwHT7t53zczpnanjDzhwSHzGodrhrcNRxLC4w27lEWVO1nm+L\n\tYGeWBeVCEoZRh6HjnLJQqStLo0QCeSHoTAi2m1OefVbQvW4U4t6d7BsZLiM89Udy3fIy\n\tMu3G24/mpum9KGBv3TCQ+ixbQky48CkGUA7UgReqFvo5C6PeOZrPODzAzcx4nC4H6ch+\n\tVzPaSRVq8+JVmMWA7nby1QcRW+k5b1XPzwW95IvjJhcaGPXPJZkoCsiTL/M9o/TcY+PV\n\tBm44AmL3NQmsYVGi16p5SmJCV3lHTOB96pzXedVdSZMGQvPwVOKAT6ylVYnZnwjU+W7s\n\t5i1A==","X-Forwarded-Encrypted":"i=1;\n\tAJvYcCUP/KRQUk+TvxEPS97gs1tehyOr0ttvmfR1/3Dq4P2lJOnExOcPe18sgsZ7ahVqG7J5qhUACX5P7cpsK+ytMEw=@lists.libcamera.org","X-Gm-Message-State":"AOJu0Yz8/+nzkishLX/lKKDSf2SeQFPnJuRmIGmIJczQeGVxEkeATP+3\n\t3a43Yq5MZZqlZD2w5IVwSvGoTg44UsNW/tGAOuAosYL0rekAG2M/4xM3jCpOYJy+VqVz25uVxmY\n\tuX9ZVCdSzgWLEVbsaUO+5FefgHV6tUqMfOF981Lw/3yhxKIHF","X-Google-Smtp-Source":"AGHT+IG18JP78OGgTD8ygzXYeHj2DCS7mCK8ATyM00IFnZ5EMDfdjdzie0DTpV5gEgdJQWWSa0DFNSUsr8ibpnj+ilo=","X-Received":"by 2002:a05:620a:3711:b0:7a2:d73:ae7d with SMTP id\n\taf79cd13be357-7ae378d4711mr2501232985a.59.1727770703123;\n\tTue, 01 Oct 2024 01:18:23 -0700 (PDT)","MIME-Version":"1.0","References":"<20240930195915.152187-1-jacopo.mondi@ideasonboard.com>\n\t<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>\n\t<CAEB1ahtJ1ApsoMg_xnRqqi18iu2S7r8hR9f5joRvAhqkgjE2Bw@mail.gmail.com>","In-Reply-To":"<CAEB1ahtJ1ApsoMg_xnRqqi18iu2S7r8hR9f5joRvAhqkgjE2Bw@mail.gmail.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Tue, 1 Oct 2024 09:18:12 +0100","Message-ID":"<CAHW6GYKZGPSBBp8iwnzuiODnbZ1qkGvO-_tgrdTZE9SrKgHe1Q@mail.gmail.com>","Subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","To":"Cheng-Hao Yang <chenghaoyang@chromium.org>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}},{"id":31506,"web_url":"https://patchwork.libcamera.org/comment/31506/","msgid":"<20241001180418.GC6117@pendragon.ideasonboard.com>","date":"2024-10-01T18:04:18","subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Mon, Sep 30, 2024 at 09:59:09PM +0200, Jacopo Mondi wrote:\n> The libcamera::Rectangle class allows defining rectangles regardless of\n> the orientation of the reference system where a rectangle is used in.\n> \n> This implies that, depending on the reference system in use, the\n> rectangle's top-left corner, as defined by libcamera, doesn't correspond\n> to the visual top-left position.\n> \n>          ^\n>          |\n>          |      -------------------\n>          |      ^                 | h\n>          |      |                 |\n>         y|      o---->-------------\n>          |               w\n>           ------------------------------->\n>          (0,0)  x\n> \n>          (0,0)  x\n>            ------------------------------>\n>           |              w\n>          y|     o---->-------------\n>           |     |                 | h\n>           |     v                 |\n>           |     -------------------\n>           |\n>           V\n> \n> Clarify that a Rectangle's top-left corner corresponds to the point\n> with the smaller x and y coordinates and that the horizontal and\n> vertical dimensions are obtained by positive increments along the\n> corresponding axes.\n> \n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> ---\n>  src/libcamera/geometry.cpp | 93 ++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 93 insertions(+)\n> \n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 000151364c7f..6eb432e5d803 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -595,6 +595,88 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * Rectangles are used to identify an area of an image. They are specified by\n>   * the coordinates of top-left corner and their horizontal and vertical size.\n>   *\n> + * libcamera canonically defines a rectangle's 'top-left' corner as the point\n> + * with the smaller 'x' and smaller 'y' coordinates. Depending on the reference\n> + * system where the rectangle is used this might not correspond to the visual\n> + * top-left corner of the rectangle.\n> + *\n> + * The rectangle's horizontal and vertical dimensions are obtained by positively\n> + * increments along the corresponding axes by the given horizontal and vertical\n> + * sizes.\n> + *\n> + * Examples:\n> + *\n> + * \\verbatim\n> +\n> +  X = top-left corner\n> +  o = reference system origin point\n> +\n> +          ^\n> +          |\n> +          |      -----------------\n> +          |     ^                 |\n> +          |     |                 |\n> +          |     X--->-------------\n> +          |\n> +          o------------------------------->\n> +         (0,0)\n> +\n> +\n> +                                      (0,0)\n> +          <-------------------------------o\n> +                                          |\n> +                 -------------<---X       |\n> +                |                 |       |\n> +                |                 V       |\n> +                 -----------------        |\n> +                                          V\n> +\n> +\n> +         (0,0)\n> +          o------------------------------->\n> +          |     X--->-------------\n> +          |     |                 |\n> +          |     v                 |\n> +          |      -----------------\n> +          |\n> +          V\n> +\n> +                                          ^\n> +                                          |\n> +                 -----------------        |\n> +                |                 ^       |\n> +                |                 |       |\n> +                 -------------<---X       |\n> +          <-------------------------------o\n> +                                      (0,0)\n> +\n> +                         ^\n> +                         |\n> +                   ------|-----------\n> +                  ^      |           |\n> +                  |      |           |\n> +                  X--->--|-----------\n> +          ---------------o---------------->\n> +                         |(0,0)\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +\n> +                         ^\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +                         |\n> +          ---------------o---------------->\n> +                    (0,0)|   ------------\n> +                         |  ^            |\n> +                         |  |            |\n> +                         |  X--->--------\n> +                         |\n> +   \\endverbatim\n> + *\n\nI think this is way too complicated and confusing. Can't we simplify\nthis patch to just the two lines below ?\n\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 000151364c7f..57894f767c68 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -594,6 +594,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n  *\n  * Rectangles are used to identify an area of an image. They are specified by\n  * the coordinates of top-left corner and their horizontal and vertical size.\n+ * By convention, the top-left corner is defined as the corner with the lowest\n+ * x and y coordinates, regardless of the origin and direction of the axes.\n  *\n  * The measure unit of the rectangle coordinates and size, as well as the\n  * reference point from which the Rectangle::x and Rectangle::y displacements\n\n\n>   * The measure unit of the rectangle coordinates and size, as well as the\n>   * reference point from which the Rectangle::x and Rectangle::y displacements\n>   * refers to, are defined by the context were rectangle is used.\n> @@ -611,6 +693,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * \\param[in] x The horizontal coordinate of the top-left corner\n>   * \\param[in] y The vertical coordinate of the top-left corner\n>   * \\param[in] size The size\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>  \n>  /**\n> @@ -620,6 +704,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * \\param[in] y The vertical coordinate of the top-left corner\n>   * \\param[in] width The width\n>   * \\param[in] height The height\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>  \n>  /**\n> @@ -632,11 +718,15 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>  /**\n>   * \\var Rectangle::x\n>   * \\brief The horizontal coordinate of the rectangle's top-left corner\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>  \n>  /**\n>   * \\var Rectangle::y\n>   * \\brief The vertical coordinate of the rectangle's top-left corner\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n>   */\n>  \n>  /**\n> @@ -685,6 +775,9 @@ Point Rectangle::center() const\n>  /**\n>   * \\fn Point Rectangle::topLeft() const\n>   * \\brief Retrieve the coordinates of the top left corner of this Rectangle\n> + *\n> + * The rectangle's top-left corner is the point with the smaller x and y values.\n> + *\n>   * \\return The Rectangle's top left corner\n>   */\n>  \n> -- \n> 2.46.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 11487BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Oct 2024 18:04:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8DFD6351F;\n\tTue,  1 Oct 2024 20:04:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F4B060553\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Oct 2024 20:04:21 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 69C902E3;\n\tTue,  1 Oct 2024 20:02:49 +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=\"Zb4788z8\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727805769;\n\tbh=BT8h6wZVSmfzF+YAH4P9473UJiKLTR5lzyNjyAYKh/w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Zb4788z827dNPWk25Q3OFOaDj8VtRMgAJnkus+1yRf/p/LvUvcf2HUoLEV5c24qdn\n\tfaS2oddUrtk4yXkB9jfp5E+qjDMb/0SigSL/iBHTPeDg2/XQHbA6hHpCKNu3XX4+iO\n\t7rIM9DDuUOP0Yyx0kVNHCZ+alhNrDjZgYDcrurPY=","Date":"Tue, 1 Oct 2024 21:04:18 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>","Subject":"Re: [PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","Message-ID":"<20241001180418.GC6117@pendragon.ideasonboard.com>","References":"<20240930195915.152187-1-jacopo.mondi@ideasonboard.com>\n\t<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","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>"}}]