savant_rs.primitives.geometry
- class savant_rs.primitives.geometry.BBox(xc, yc, width, height)
- almost_eq(other, eps)
- as_ltrb()
Returns (left, top, right, bottom) coordinates.
- as_ltrb_int()
Returns (left, top, right, bottom) coordinates rounded to integers.
- as_ltwh()
Returns (left, top, width, height) coordinates.
- as_ltwh_int()
Returns (left, top, width, height) coordinates rounded to integers.
- as_polygonal_area()
- as_xcycwh()
Returns (xc, yc, width, height) coordinates.
- as_xcycwh_int()
Returns (xc, yc, width, height) coordinates rounded to integers.
- bottom
- static constructor(xc, yc, width, height)
Creates a new object. Alias to the
__init__
method.
- eq(other)
- get_visual_box(padding, border_width, max_x, max_y)
- height
- ioo(other)
- ios(other)
- iou(other)
- is_modified()
- left
- static ltrb(left, top, right, bottom)
Creates a new object from (left, top, right, bottom) coordinates.
- static ltwh(left, top, width, height)
Creates a new object from (left, top, width, height) coordinates.
- new_padded(padding)
- right
- scale(scale_x, scale_y)
- shift(dx, dy)
- top
- vertices
- vertices_int
- vertices_rounded
- width
- wrapping_box
- xc
- yc
- class savant_rs.primitives.geometry.IntersectionKind
- Cross = Cross
- Enter = Enter
- Inside = Inside
- Leave = Leave
- Outside = Outside
- class savant_rs.primitives.geometry.PolygonalArea(vertices, tags=None)
- build_polygon()
- contains(p)
- contains_many_points(points)
- crossed_by_segment(segment)
- crossed_by_segments(segments)
- get_tag(edge)
- is_self_intersecting()
- static points_positions(polys, points, no_gil=False)
- static segments_intersections(polys, segments, no_gil=False)
- class savant_rs.primitives.geometry.RBBox(xc, yc, width, height, angle=None)
Represents a bounding box with an optional rotation angle in degrees.
- almost_eq(other, eps)
Compares boxes geometrically with given precision.
- Parameters:
other (
RBBox
) – other bbox to compare witheps (float) – precision
- Returns:
True if boxes are geometrically equal, False otherwise.
- Return type:
bool
- angle
Access and change the angle of the bbox. To unset the angle use None as a value.
- area
Computes the area of bbox
- Returns:
area of bbox
- Return type:
float
- as_ltrb()
Returns (left, top, right, bottom) coordinates.
- as_ltrb_int()
Returns (left, top, right, bottom) coordinates rounded to integers.
- as_ltwh()
Returns (left, top, width, height) coordinates.
- as_ltwh_int()
Returns (left, top, width, height) coordinates rounded to integers.
- as_polygonal_area()
Returns bbox as a polygonal area. The property is GIL-free.
- Returns:
polygonal area of the bbox
- Return type:
- as_xcycwh()
Returns (xc, yc, width, height) coordinates.
- as_xcycwh_int()
Returns (xc, yc, width, height) coordinates rounded to integers.
- bottom
- static constructor(xc, yc, width, height, angle=None)
Alias to the
__init__
method.- Parameters:
xc (float) – x center of bbox
yc (float) – y center of bbox
width (float) – width of bbox
height (float) – height of bbox
angle (float, optional) – angle of bbox
- Returns:
new bbox
- Return type:
- copy()
Returns a copy of the RBBox object. Modification flag is reset.
- Returns:
A copy of the RBBox object
- Return type:
- eq(other)
Compares boxes geometrically.
- Parameters:
other (
RBBox
) – other bbox to compare with- Returns:
True if boxes are geometrically equal, False otherwise.
- Return type:
bool
- get_visual_box(padding, border_width)
Returns rotated bounding box wrapping the bbox with geometry corrected with respect to the padding and border width. The property is GIL-free.
- Parameters:
padding (
savant_rs.draw_spec.PaddingDraw
) – padding of the bboxborder_width (int) – border width of the bbox
- Returns:
wrapping bbox
- Return type:
- height
Access and change the height of the bbox.
- ioo(other)
Calculates the intersection over other (IoO) of two rotated bounding boxes.
- Parameters:
other (
RBBox
) – other rotated bounding box- Returns:
intersection over other (IoO) of two rotated bounding boxes
- Return type:
float
- ios(other)
Calculates the intersection over self (IoS) of two rotated bounding boxes.
- Parameters:
other (
RBBox
) – other rotated bounding box- Returns:
intersection over self (IoS) of two rotated bounding boxes
- Return type:
float
- iou(other)
Calculates the intersection over union (IoU) of two rotated bounding boxes.
- Parameters:
other (
RBBox
) – other rotated bounding box- Returns:
intersection over union (IoU) of two rotated bounding boxes
- Return type:
float
- is_modified()
Flag indicating if the bbox has been modified.
- left
- static ltrb(left, top, right, bottom)
Creates a new object from (left, top, right, bottom) coordinates.
- static ltwh(left, top, width, height)
Creates a new object from (left, top, width, height) coordinates.
- new_padded(padding)
Returns rotated bounding box wrapping the bbox. The property is GIL-free.
- Parameters:
padding (
savant_rs.draw_spec.PaddingDraw
) – padding of the bbox- Returns:
wrapping bbox
- Return type:
- right
- scale(scale_x, scale_y)
Scales the bbox by given factors. The function is GIL-free. Scaling happens in-place.
- set_modifications(value)
Resets the modification flag.
- shift(dx, dy)
Shifts the center of the rotated bounding box by the given amount.
- Parameters:
dx (float) – amount to shift the center of the rotated bounding box in the x-direction
dy (float) – amount to shift the center of the rotated bounding box in the y-direction
- Return type:
None
- top
- vertices
Returns vertices of the bbox. The property is GIL-free.
- Returns:
vertices of the bbox
- Return type:
list of tuples (float, float)
- vertices_int
Returns vertices of the bbox rounded to integers. The property is GIL-free.
- Returns:
vertices of the bbox rounded to integers
- Return type:
list of tuples (int, int)
- vertices_rounded
Returns vertices of the bbox rounded to 2 decimal digits. The property is GIL-free.
- Returns:
vertices of the bbox rounded to 2 decimal digits
- Return type:
list of tuples (float, float)
- width
Access and change the width of the bbox.
- width_to_height_ratio
Access the ratio between width and height.
- wrapping_box
Returns axis-aligned bounding box wrapping the bbox. The property is GIL-free.
- Returns:
axis-aligned bounding box wrapping the bbox
- Return type:
- xc
Access and change the x center of the bbox.
- yc
Access and change the y center of the bbox.