Rect¶
- class Rect(*args, **kwargs)¶
Bases:
pybind11_object
Defines a rectangle in the plane.
A rectangle is internally represented as an upper-left corner and a width and height, but it is normally expressed as an upper-left corner and bottom-right corner.
Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.
Generally, width = right - left + 1 and height = bottom - top + 1.
We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.
The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.
A vpRect can be constructed with a set of left, top, width and height double. After creation the dimensions can be changed, e.g. with setLeft() , setRight() , setTop() and setBottom() , or by setting sizes, e.g. setWidth() , setHeight()
Overloaded function.
__init__(self: visp._visp.core.Rect) -> None
Constructs a default rectangle with the top , left corner set to (0,0) and width and height set to 1.
__init__(self: visp._visp.core.Rect, left: float, top: float, width: float, height: float) -> None
Constructs a rectangle with the top , left corner and width and height .
__init__(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, width: float, height: float) -> None
Constructs a rectangle with topLeft the top-left corner location and width and height the rectangle size.
- Parameters:
- topLeft
coordinates of the top/left corner.
__init__(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, bottomRight: visp._visp.core.ImagePoint) -> None
Constructs a rectangle with topLeft the top-left corner location and bottomRight the bottom-right corner.
__init__(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None
Constructs a rectangle that is a copy of r .
__init__(self: visp._visp.core.Rect, ip: list[visp._visp.core.ImagePoint]) -> None
Methods
Overloaded function.
Returns the area of the rectangle.
Returns the bottom coordinate of the rectangle.
Returns the bottom-left position of the rectangle.
Returns the bottom-right coordinate of the rectangle.
Overloaded function.
Returns the height of the rectangle.
Returns the left coordinate of the rectangle.
Returns the right coordinate of the rectangle.
Returns the size of the rectangle.
Returns the top coordinate of the rectangle.
Returns the top-left position of the rectangle.
Returns the top-right position of the rectangle.
Returns the width of the rectangle.
Returns true if the point belongs to the rectangle.
Overloaded function.
Overloaded function.
Sets the bottom edge position of the rectangle to pos.
Sets the bottom-right position of the rectangle.
Sets the height of the rectangle to h .
Sets the left edge position of the rectangle to pos.
Sets the coordinates of the rectangle's top left corner to (left, top), and its size to (width, height).
Sets the right edge position of the rectangle to pos.
Sets the top edge position of the rectangle to pos.
Sets the top-left position of the rectangle.
Sets the width of the rectangle to w .
Inherited Methods
Operators
- return:
Intersection rectangle or null rectangle if the two rectangles do not intersect.
__doc__
- return:
true if both objects are similar, false otherwise.
Overloaded function.
__module__
- return:
true if both objects differ, false otherwise.
__repr__
Attributes
__annotations__
- __and__(self, r: visp._visp.core.Rect) visp._visp.core.Rect ¶
- Returns:
Intersection rectangle or null rectangle if the two rectangles do not intersect.
- __eq__(self, r: visp._visp.core.Rect) bool ¶
- Returns:
true if both objects are similar, false otherwise.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.core.Rect) -> None
Constructs a default rectangle with the top , left corner set to (0,0) and width and height set to 1.
__init__(self: visp._visp.core.Rect, left: float, top: float, width: float, height: float) -> None
Constructs a rectangle with the top , left corner and width and height .
__init__(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, width: float, height: float) -> None
Constructs a rectangle with topLeft the top-left corner location and width and height the rectangle size.
- Parameters:
- topLeft
coordinates of the top/left corner.
__init__(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, bottomRight: visp._visp.core.ImagePoint) -> None
Constructs a rectangle with topLeft the top-left corner location and bottomRight the bottom-right corner.
__init__(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None
Constructs a rectangle that is a copy of r .
__init__(self: visp._visp.core.Rect, ip: list[visp._visp.core.ImagePoint]) -> None
- __ne__(self, r: visp._visp.core.Rect) bool ¶
- Returns:
true if both objects differ, false otherwise.
- getBottomLeft(self) visp._visp.core.ImagePoint ¶
Returns the bottom-left position of the rectangle.
Note
See getTopLeft() , getTopRight() , getBottomRight() , getBottom() , getLeft()
- getBottomRight(self) visp._visp.core.ImagePoint ¶
Returns the bottom-right coordinate of the rectangle.
Note
See getTopLeft() , getTopRight() , getBottomLeft() , getBottom() , getRight()
- getCenter(*args, **kwargs)¶
Overloaded function.
getCenter(self: visp._visp.core.Rect) -> tuple[float, float]
Returns the center point of the rectangle. The center point coordinates are ( x , y ).
The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.
Note
See moveCenter()
- Returns:
A tuple containing:
x
y
getCenter(self: visp._visp.core.Rect) -> visp._visp.core.ImagePoint
Returns the center point of the rectangle. The center point coordinates are ( x , y ).
The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.
Note
See moveCenter()
- getHeight(self) float ¶
Returns the height of the rectangle. The height includes both the top and bottom edges, i.e. height = bottom - top + 1.
Note
See getWidth()
- getLeft(self) float ¶
Returns the left coordinate of the rectangle.
Note
See getTopLeft() , getRight()
- getTop(self) float ¶
Returns the top coordinate of the rectangle.
Note
See getTopLeft() , getBottom()
- getTopLeft(self) visp._visp.core.ImagePoint ¶
Returns the top-left position of the rectangle.
Note
See getTopRight() , getBottomRight() , getBottomLeft() , getTop() , getLeft()
- getTopRight(self) visp._visp.core.ImagePoint ¶
Returns the top-right position of the rectangle.
Note
See getTopLeft() , getBottomRight() , getBottomLeft() , getTop() , getRight()
- getWidth(self) float ¶
Returns the width of the rectangle. The width includes both the left and right edges, i.e. width = right - left + 1.
Note
See getHeight()
- isInside(self, ip: visp._visp.core.ImagePoint) bool ¶
Returns true if the point belongs to the rectangle.
Check if an image point belongs to the rectangle.
- Parameters:
- ip: visp._visp.core.ImagePoint¶
the image point.
- Returns:
Returns true if the point belongs to the rectangle.
- moveCenter(*args, **kwargs)¶
Overloaded function.
moveCenter(self: visp._visp.core.Rect, x: float, y: float) -> None
Sets the center point of the rectangle to ( x , y ), leaving the size unchanged.
Note
See getCenter()
moveCenter(self: visp._visp.core.Rect, center: visp._visp.core.ImagePoint) -> None
Center the rectangle to the image point given as parameter, leaving the size unchanged.
Note
See getCenter()
- set(*args, **kwargs)¶
Overloaded function.
set(self: visp._visp.core.Rect, left: float, top: float, width: float, height: float) -> None
Set the rectangle with the top , left corner and width and height .
set(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, width: float, height: float) -> None
Set the rectangle with topLeft the top-left corner location and width and height the rectangle size.
- Parameters:
- topLeft
coordinates of the top-left corner.
set(self: visp._visp.core.Rect, topLeft: visp._visp.core.ImagePoint, bottomRight: visp._visp.core.ImagePoint) -> None
Set the rectangle with topLeft the top-left corner location and bottomRight the bottom-right corner.
- Parameters:
- topLeft
coordinates of the top-left corner.
- bottomRight
coordinates of the bottom-right corner.
set(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None
Set the rectangle from r .
set(self: visp._visp.core.Rect, ip: list[visp._visp.core.ImagePoint]) -> None
Set the rectangle as the bounding box of a vector of image points.
- Parameters:
- ip
Vector of image points. At least 1 points is mandatory, otherwise an exception is thrown.
- setBottom(self, pos: float) None ¶
Sets the bottom edge position of the rectangle to pos. May change the height of the rectangle, but will never change the top edge position the rectangle.
Note
See setTop()
- setBottomRight(self, bottomRight: visp._visp.core.ImagePoint) None ¶
Sets the bottom-right position of the rectangle. Will never change the top-left position the rectangle.
Note
See setTopLeft()
- setHeight(self, h: float) None ¶
Sets the height of the rectangle to h . The top edge is not moved, but the bottom edge may be moved.
Note
See setWidth()
- setLeft(self, pos: float) None ¶
Sets the left edge position of the rectangle to pos. May change the right edge position of the rectangle, but will never change the width of the rectangle.
Note
See setRight()
- setRect(self, l: float, t: float, w: float, h: float) None ¶
Sets the coordinates of the rectangle’s top left corner to (left, top), and its size to (width, height).
- setRight(self, pos: float) None ¶
Sets the right edge position of the rectangle to pos. May change the width of the rectangle, but will never change the left edge position of the rectangle.
Note
See setLeft()
- setTop(self, pos: float) None ¶
Sets the top edge position of the rectangle to pos. May change the bottom edge position of the rectangle, but will never change the height of the rectangle.
Note
See setBottom()
- setTopLeft(self, topLeft: visp._visp.core.ImagePoint) None ¶
Sets the top-left position of the rectangle. May change the bottom edge position of the rectangle, but will never change the height of the rectangle.
Note
See setBottomRight()
- setWidth(self, w: float) None ¶
Sets the width of the rectangle to w . The right edge is changed, but not the left edge.
Note
See setHeight()
-
__hash__ =
None
¶