deepness.processing.processing_utils.BoundingBox¶
- class BoundingBox(x_min: int, x_max: int, y_min: int, y_max: int)¶
Bases:
objectDescribes a bounding box rectangle. Similar to cv2.Rect
Methods
Apply (x,y) offset to keeping coordinates
Calculate intersection over smaler area (IoS) between two bounding boxes
Calculate overlap between two bounding boxes in pixels
Get 4 points (corners) describing the detection rectangle, each point in (x, y) format
Calculate bounding box reactangle area
Returns the center of the bounding box as a tuple (x, y)
Returns the shape of the bounding box as a tuple (height, width)
Returns the bounding box as a tuple of slices (y_slice, x_slice)
Returns the bounding box as a tuple (x_min, y_min, width, height)
Returns the bounding box as a tuple (x_min, y_min, x_max, y_max)
Attributes
x_minx_maxy_miny_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]