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.

  1. __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.

  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 .

  1. __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.

  1. __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.

  1. __init__(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None

Constructs a rectangle that is a copy of r .

  1. __init__(self: visp._visp.core.Rect, ip: list[visp._visp.core.ImagePoint]) -> None

Create a 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.

Methods

__init__

Overloaded function.

getArea

Returns the area of the rectangle.

getBottom

Returns the bottom coordinate of the rectangle.

getBottomLeft

Returns the bottom-left position of the rectangle.

getBottomRight

Returns the bottom-right coordinate of the rectangle.

getCenter

Overloaded function.

getHeight

Returns the height of the rectangle.

getLeft

Returns the left coordinate of the rectangle.

getRight

Returns the right coordinate of the rectangle.

getSize

Returns the size of the rectangle.

getTop

Returns the top coordinate of the rectangle.

getTopLeft

Returns the top-left position of the rectangle.

getTopRight

Returns the top-right position of the rectangle.

getWidth

Returns the width of the rectangle.

isInside

Returns true if the point belongs to the rectangle.

moveCenter

Overloaded function.

set

Overloaded function.

setBottom

Sets the bottom edge position of the rectangle to pos.

setBottomRight

Sets the bottom-right position of the rectangle.

setHeight

Sets the height of the rectangle to h .

setLeft

Sets the left edge position of the rectangle to pos.

setRect

Sets the coordinates of the rectangle's top left corner to (left, top), and its size to (width, height).

setRight

Sets the right edge position of the rectangle to pos.

setTop

Sets the top edge position of the rectangle to pos.

setTopLeft

Sets the top-left position of the rectangle.

setWidth

Sets the width of the rectangle to w .

Inherited Methods

Operators

__and__

return:

Intersection rectangle or null rectangle if the two rectangles do not intersect.

__doc__

__eq__

return:

true if both objects are similar, false otherwise.

__hash__

__init__

Overloaded function.

__module__

__ne__

return:

true if both objects differ, false otherwise.

__repr__

Attributes

__annotations__

__hash__

__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.

  1. __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.

  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 .

  1. __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.

  1. __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.

  1. __init__(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None

Constructs a rectangle that is a copy of r .

  1. __init__(self: visp._visp.core.Rect, ip: list[visp._visp.core.ImagePoint]) -> None

Create a 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.

__ne__(self, r: visp._visp.core.Rect) bool
Returns:

true if both objects differ, false otherwise.

getArea(self) float

Returns the area of the rectangle.

getBottom(self) float

Returns the bottom coordinate of the rectangle.

Note

See getRight()

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.

  1. 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

  1. 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()

getRight(self) float

Returns the right coordinate of the rectangle.

Note

See getLeft()

getSize(self) float

Returns the size of the rectangle.

Note

See getWidth() , getHeight()

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.

  1. 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()

  1. 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.

  1. 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 .

  1. 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.

  1. 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.

  1. set(self: visp._visp.core.Rect, r: visp._visp.core.Rect) -> None

Set the rectangle from r .

  1. 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).

Parameters:
l: float

horizontal position of the rectangle upper/left corner position.

t: float

vertical position of the rectangle upper/left corner position.

w: float

rectangle width.

h: float

rectangle 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