deepness.processing.processing_utils.BoundingBox

class BoundingBox(x_min: int, x_max: int, y_min: int, y_max: int)

Bases: object

Describes a bounding box rectangle. Similar to cv2.Rect

Methods

apply_offset

Apply (x,y) offset to keeping coordinates

calculate_intersection_over_smaler_area

Calculate intersection over smaler area (IoS) between two bounding boxes

calculate_overlap_in_pixels

Calculate overlap between two bounding boxes in pixels

get_4_corners

Get 4 points (corners) describing the detection rectangle, each point in (x, y) format

get_area

Calculate bounding box reactangle area

get_center

Returns the center of the bounding box as a tuple (x, y)

get_shape

Returns the shape of the bounding box as a tuple (height, width)

get_slice

Returns the bounding box as a tuple of slices (y_slice, x_slice)

get_xywh

Returns the bounding box as a tuple (x_min, y_min, width, height)

get_xyxy

Returns the bounding box as a tuple (x_min, y_min, x_max, y_max)

Attributes

x_min

x_max

y_min

y_max

apply_offset(offset_x: int, offset_y: int)

Apply (x,y) offset to keeping coordinates

Parameters:
  • offset_x (int) – x-axis offset in pixels

  • offset_y (int) – y-axis offset in pixels

calculate_intersection_over_smaler_area(other) float

Calculate intersection over smaler area (IoS) between two bounding boxes

Parameters:

other (BoundingBox) – Other bounding bo

Returns:

Value between 0 and 1

Return type:

float

calculate_overlap_in_pixels(other) float

Calculate overlap between two bounding boxes in pixels

Parameters:

other (BoundingBox) – Other bounding box

Returns:

Overlap in pixels

Return type:

float

get_4_corners() List[Tuple]

Get 4 points (corners) describing the detection rectangle, each point in (x, y) format

Returns:

List of 4 rectangle corners in (x, y) format

Return type:

List[Tuple]

get_area() float

Calculate bounding box reactangle area

Returns:

Bounding box area

Return type:

float

get_center() Tuple[int, int]

Returns the center of the bounding box as a tuple (x, y)

Returns:

(x, y)

Return type:

Tuple[int, int]

get_shape() Tuple[int, int]

Returns the shape of the bounding box as a tuple (height, width)

Returns:

(height, width)

Return type:

tuple

get_slice() Tuple[slice, slice]

Returns the bounding box as a tuple of slices (y_slice, x_slice)

Returns:

(y_slice, x_slice)

Return type:

Tuple[slice, slice]

get_xywh() Tuple[int, int, int, int]

Returns the bounding box as a tuple (x_min, y_min, width, height)

Returns:

(x_min, y_min, width, height)

Return type:

Tuple[int, int, int, int]

get_xyxy() Tuple[int, int, int, int]

Returns the bounding box as a tuple (x_min, y_min, x_max, y_max)

Returns:

(x_min, y_min, x_max, y_max)

Return type:

Tuple[int, int, int, int]