pixano.core.bbox
BBox(coords, format, is_normalized=True, confidence=None)
Bases: PixanoType
, BaseModel
Bounding box type using coordinates in xyxy or xywh format
Attributes:
Name | Type | Description |
---|---|---|
coords |
list[float]
|
List of coordinates in given format |
format |
str
|
Coordinates format, 'xyxy' or 'xywh' |
is_normalized |
bool
|
True if coordinates are normalized to image size |
confidence |
float
|
Bounding box confidence if predicted |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords
|
list[float]
|
List of coordinates in given format |
required |
format
|
str
|
Coordinates format, 'xyxy' or 'xywh' |
required |
is_normalized
|
bool
|
True if coordinates are normalized to image size. Defaults to True. |
True
|
confidence
|
float
|
Bounding box confidence if predicted. Defaults to None. |
None
|
Source code in pixano/core/bbox.py
confidence: float
property
Return bounding box confidence
Returns:
Type | Description |
---|---|
float
|
Bounding box confidence if predicted, else None |
coords: list[float]
property
format: str
property
Return bounding box coordinates format
Returns:
Type | Description |
---|---|
str
|
Coordinates format, 'xyxy' or 'xywh' |
is_normalized: bool
property
Return bounding box normalization information
Returns:
Type | Description |
---|---|
bool
|
True if coordinates are normalized to image size |
is_predicted: bool
property
Return True if bounding box is predicted and has a confidence value
Returns:
Type | Description |
---|---|
bool
|
True if bounding box is predicted and has a confidence value |
xywh_coords: list[float]
property
xyxy_coords: list[float]
property
denormalize(height, width)
Return bounding box with coordinates denormalized from image size
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height
|
int
|
Image height |
required |
width
|
int
|
Image width |
required |
Returns:
Type | Description |
---|---|
BBox
|
Bounding box with coordinates denormalized from image size |
Source code in pixano/core/bbox.py
from_mask(mask)
staticmethod
Create bounding box using a NumPy array mask
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
ndarray
|
NumPy array mask |
required |
Returns:
Type | Description |
---|---|
Bbox
|
Bounding box |
Source code in pixano/core/bbox.py
from_rle(rle)
staticmethod
Create bounding box using a RLE mask
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rle
|
CompressedRLE
|
RLE mask |
required |
Returns:
Type | Description |
---|---|
Bbox
|
Bounding box |
from_xywh(xywh, confidence=None)
staticmethod
Create bounding box using normalized xywh coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xywh
|
list[float]
|
List of coordinates in xywh format |
required |
confidence
|
float
|
Bounding box confidence if predicted. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Bbox
|
Bounding box |
Source code in pixano/core/bbox.py
from_xyxy(xyxy, confidence=None)
staticmethod
Create bounding box using normalized xyxy coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xyxy
|
list[float]
|
List of coordinates in xyxy format |
required |
confidence
|
float
|
Bounding box confidence if predicted. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Bbox
|
Bounding box |
Source code in pixano/core/bbox.py
normalize(height, width)
Return bounding box with coordinates normalized to image size
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height
|
int
|
Image height |
required |
width
|
int
|
Image width |
required |
Returns:
Type | Description |
---|---|
BBox
|
Bounding box with coordinates normalized to image size |
Source code in pixano/core/bbox.py
to_struct()
staticmethod
Return BBox type as PyArrow Struct
Returns:
Type | Description |
---|---|
StructType
|
Custom type corresponding PyArrow Struct |