dataeval.utils.preprocessing.BoundingBox¶
-
class dataeval.utils.preprocessing.BoundingBox(v1, v2, v3, v4, *, bbox_format=
BoundingBoxFormat.XYXY, image_shape=None)¶ A bounding box representation that supports multiple coordinate formats.
- Parameters:¶
- v1 : float¶
First coordinate value
- v2 : float¶
Second coordinate value
- v3 : float¶
Third coordinate value
- v4 : float¶
Fourth coordinate value
- bbox_format : BoundingBoxFormat, default BoundingBoxFormat.XYXY¶
Input format of the coordinates
- image_shape : tuple[int, ...] or None, default None¶
Shape of the image in CHW format
Examples
Create a bounding box in XYXY format:
>>> bbox = BoundingBox(10, 20, 100, 150, bbox_format=BoundingBoxFormat.XYXY) >>> bbox.xyxy (10.0, 20.0, 100.0, 150.0)Convert to different formats:
>>> bbox.xywh (10.0, 20.0, 90.0, 130.0) >>> bbox.cxcywh (55.0, 85.0, 90.0, 130.0)With image shape for YOLO format:
>>> bbox = BoundingBox(0.5, 0.5, 0.2, 0.3, bbox_format=BoundingBoxFormat.YOLO, image_shape=(3, 224, 224)) >>> bbox.xyxy (89.6, 78.4, 134.4, 145.6)- property cxcywh : tuple[float, float, float, float]¶
Get coordinates in CXCYWH format (center_x, center_y, width, height).
- Return type:¶
tuple[float, float, float, float]
- property xywh : tuple[float, float, float, float]¶
Get coordinates in XYWH format (x, y, width, height).
- Return type:¶
tuple[float, float, float, float]
- property xyxy : tuple[float, float, float, float]¶
Get coordinates in XYXY format (x0, y0, x1, y1).
- Return type:¶
tuple[float, float, float, float]