Bounding Box
BBox
Bases: DataModel
A data model representing a bounding box.
Attributes:
-
title
(str
) –The title or label associated with the bounding box.
-
coords
(list[int]
) –A list of four bounding box coordinates.
The bounding box follows the PASCAL VOC format, where: - (x1, y1) represents the pixel coordinates of the top-left corner. - (x2, y2) represents the pixel coordinates of the bottom-right corner.
from_albumentations
staticmethod
Create a bounding box from Albumentations format.
Albumentations represents bounding boxes as [x_min, y_min, x_max, y_max]
with normalized coordinates (values between 0 and 1) relative to the image size.
Parameters:
-
coords
(Sequence[float]
) –The bounding box coordinates in Albumentations format.
-
img_size
(Sequence[int]
) –The reference image size as
[width, height]
. -
title
(str
, default:''
) –The title or label of the bounding box. Defaults to an empty string.
Returns:
-
BBox
(BBox
) –The bounding box data model.
Source code in datachain/model/bbox.py
from_coco
staticmethod
Create a bounding box from COCO format.
COCO format represents bounding boxes as [x_min, y_min, width, height], where: - (x_min, y_min) are the pixel coordinates of the top-left corner. - width and height define the size of the bounding box in pixels.
Parameters:
-
coords
(Sequence[float]
) –The bounding box coordinates in COCO format.
-
title
(str
, default:''
) –The title of the bounding box.
Returns:
-
BBox
(BBox
) –The bounding box data model.
Source code in datachain/model/bbox.py
from_voc
staticmethod
Create a bounding box from PASCAL VOC format.
PASCAL VOC format represents bounding boxes as [x_min, y_min, x_max, y_max], where: - (x_min, y_min) are the pixel coordinates of the top-left corner. - (x_max, y_max) are the pixel coordinates of the bottom-right corner.
Parameters:
-
coords
(Sequence[float]
) –The bounding box coordinates in VOC format.
-
title
(str
, default:''
) –The title of the bounding box.
Returns:
-
BBox
(BBox
) –The bounding box data model.
Source code in datachain/model/bbox.py
from_yolo
staticmethod
Create a bounding box from YOLO format.
YOLO format represents bounding boxes as [x_center, y_center, width, height], where: - (x_center, y_center) are the normalized coordinates of the box center. - width and height normalized values define the size of the bounding box.
Parameters:
-
coords
(Sequence[float]
) –The bounding box coordinates in YOLO format.
-
img_size
(Sequence[int]
) –The reference image size as
[width, height]
. -
title
(str
, default:''
) –The title of the bounding box.
Returns:
-
BBox
(BBox
) –The bounding box data model.
Source code in datachain/model/bbox.py
point_inside
Return True if the point is inside the bounding box.
Assumes that if the point is on the edge of the bounding box, it is considered inside.
Source code in datachain/model/bbox.py
pose_inside
Return True if the pose is inside the bounding box.
to_albumentations
Convert the bounding box coordinates to Albumentations format.
Albumentations represents bounding boxes as [x_min, y_min, x_max, y_max]
with normalized coordinates (values between 0 and 1) relative to the image size.
Parameters:
Returns:
Source code in datachain/model/bbox.py
to_coco
Return the bounding box coordinates in COCO format.
COCO format represents bounding boxes as [x_min, y_min, width, height], where: - (x_min, y_min) are the pixel coordinates of the top-left corner. - width and height define the size of the bounding box in pixels.
Returns:
Source code in datachain/model/bbox.py
to_voc
Return the bounding box coordinates in PASCAL VOC format.
PASCAL VOC format represents bounding boxes as [x_min, y_min, x_max, y_max], where: - (x_min, y_min) are the pixel coordinates of the top-left corner. - (x_max, y_max) are the pixel coordinates of the bottom-right corner.
Returns:
Source code in datachain/model/bbox.py
to_yolo
Return the bounding box coordinates in YOLO format.
YOLO format represents bounding boxes as [x_center, y_center, width, height], where: - (x_center, y_center) are the normalized coordinates of the box center. - width and height normalized values define the size of the bounding box.
Parameters:
Returns:
Source code in datachain/model/bbox.py
OBBox
Bases: DataModel
A data model for representing oriented bounding boxes.
Attributes:
-
title
(str
) –The title of the oriented bounding box.
-
coords
(list[int]
) –The coordinates of the oriented bounding box.
The oriented bounding box is defined by four points
- (x1, y1): The first corner of the box.
- (x2, y2): The second corner of the box.
- (x3, y3): The third corner of the box.
- (x4, y4): The fourth corner of the box.