[PATCH v10 1/5] libcamera: geometry: Clarify Rectangle's top-left corner
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Wed Oct 2 13:44:34 CEST 2024
Hi Jacopo,
Thank you for the patch.
On Wed, Oct 02, 2024 at 07:49:58AM +0200, Jacopo Mondi wrote:
> The libcamera::Rectangle class allows defining rectangles regardless of
> the orientation of the reference system where a rectangle is used in.
>
> This implies that, depending on the reference system in use, the
> rectangle's top-left corner, as defined by libcamera, doesn't correspond
> to the visual top-left position.
>
> ^
> |
> | -------------------
> | ^ | h
> | | |
> y| o---->-------------
> | w
> ------------------------------->
> (0,0) x
>
> (0,0) x
> ------------------------------>
> | w
> y| o---->-------------
> | | | h
> | v |
> | -------------------
> |
> V
>
> Clarify that a Rectangle's top-left corner corresponds to the point
> with the smaller x and y coordinates and that the horizontal and
> vertical dimensions are obtained by positive increments along the
> corresponding axes.
>
> Signed-off-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
> Reviewed-by: Harvey Yang <chenghaoyang at chromium.org>
> Reviewed-by: David Plowman <david.plowman at raspberrypi.com>
> ---
> src/libcamera/geometry.cpp | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
> index 000151364c7f..85a7f53a6f6c 100644
> --- a/src/libcamera/geometry.cpp
> +++ b/src/libcamera/geometry.cpp
> @@ -594,6 +594,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
> *
> * Rectangles are used to identify an area of an image. They are specified by
> * the coordinates of top-left corner and their horizontal and vertical size.
> + * By convention, the top-left corner is defined as the corner with the lowest
> + * x and y coordinates, regardless of the origin and direction of the axes.
> *
> * The measure unit of the rectangle coordinates and size, as well as the
> * reference point from which the Rectangle::x and Rectangle::y displacements
> @@ -611,6 +613,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
> * \param[in] x The horizontal coordinate of the top-left corner
> * \param[in] y The vertical coordinate of the top-left corner
> * \param[in] size The size
> + *
> + * The rectangle's top-left corner is the point with the smaller x and y values.
You could skip this, it doesn't have to be repeated everywhere. The
documentation in the \class is good enough.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> */
>
> /**
> @@ -620,6 +624,8 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
> * \param[in] y The vertical coordinate of the top-left corner
> * \param[in] width The width
> * \param[in] height The height
> + *
> + * The rectangle's top-left corner is the point with the smaller x and y values.
> */
>
> /**
> @@ -632,11 +638,15 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)
> /**
> * \var Rectangle::x
> * \brief The horizontal coordinate of the rectangle's top-left corner
> + *
> + * The rectangle's top-left corner is the point with the smaller x and y values.
> */
>
> /**
> * \var Rectangle::y
> * \brief The vertical coordinate of the rectangle's top-left corner
> + *
> + * The rectangle's top-left corner is the point with the smaller x and y values.
> */
>
> /**
> @@ -685,6 +695,9 @@ Point Rectangle::center() const
> /**
> * \fn Point Rectangle::topLeft() const
> * \brief Retrieve the coordinates of the top left corner of this Rectangle
> + *
> + * The rectangle's top-left corner is the point with the smaller x and y values.
> + *
> * \return The Rectangle's top left corner
> */
>
> --
> 2.46.1
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list