{"id":21440,"url":"https://patchwork.libcamera.org/api/1.1/patches/21440/?format=json","web_url":"https://patchwork.libcamera.org/patch/21440/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","date":"2024-09-30T19:59:09","name":"[v9,1/5] libcamera: geometry: Clarify Rectangle's top-left corner","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"844f1fc27d69efa3ec3e6160ebd56eef5a4e595c","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21440/mbox/","series":[{"id":4642,"url":"https://patchwork.libcamera.org/api/1.1/series/4642/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4642","date":"2024-09-30T19:59:08","name":"Add Face Detection Controls","version":9,"mbox":"https://patchwork.libcamera.org/series/4642/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21440/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21440/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 6824CC3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Sep 2024 19:59:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1173A63518;\n\tMon, 30 Sep 2024 21:59:39 +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 9538A63516\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 21:59:31 +0200 (CEST)","from ideasonboard.com (unknown [95.131.46.153])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EC1BBA2F;\n\tMon, 30 Sep 2024 21:57:58 +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=\"uD8UHZfE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727726280;\n\tbh=x+I7ykB+ojLGHL4GByGX0cx9G+UWeYOz0fLsOocL+64=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=uD8UHZfEQ2X7IkDXhTDOugEskqzUfyPH9DgcTPDvUhazFduGKjwZ5jRJ5+P/KtNaE\n\tvI4y0438bdqAtWIjXthcL/uWXGTPD8OKwLMw+m4u0iTMLTSmP7x53iRJrC4f/S2UfU\n\twyLuVlp/8JYlQnbiYSVuwg2+0t5U4N9ZXHijnCXY=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tHarvey Yang <chenghaoyang@google.com>","Subject":"[PATCH v9 1/5] libcamera: geometry: Clarify Rectangle's top-left\n\tcorner","Date":"Mon, 30 Sep 2024 21:59:09 +0200","Message-ID":"<20240930195915.152187-2-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.46.1","In-Reply-To":"<20240930195915.152187-1-jacopo.mondi@ideasonboard.com>","References":"<20240930195915.152187-1-jacopo.mondi@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":"The libcamera::Rectangle class allows defining rectangles regardless of\nthe orientation of the reference system where a rectangle is used in.\n\nThis implies that, depending on the reference system in use, the\nrectangle's top-left corner, as defined by libcamera, doesn't correspond\nto 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\nClarify that a Rectangle's top-left corner corresponds to the point\nwith the smaller x and y coordinates and that the horizontal and\nvertical dimensions are obtained by positive increments along the\ncorresponding axes.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/geometry.cpp | 93 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 93 insertions(+)","diff":"diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 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","prefixes":["v9","1/5"]}