Skip to main content

BoundingBox2D

Represents a 2D bounding box using top-left corner coordinates plus width and height.

Properties:

Property

Type

Description

x

int

Top-left corner X coordinate

y

int

Top-left corner Y coordinate

width

int

Bounding box width

height

int

Bounding box height

Read-only properties:

Property

Type

Description

center_x

float

Center point X coordinate, calculated from x and width

center_y

float

Center point Y coordinate, calculated from y and height

area

int

Bounding box area, calculated from width and height

BoundingBox2D​

Signature:

BoundingBox2D(x: int, y: int, width: int, height: int)

Description:

Constructs a BoundingBox2D instance. This type is an immutable dataclass.

Parameters:

Parameter

Type

Required

Description

x

int

Yes

Top-left corner X coordinate

y

int

Yes

Top-left corner Y coordinate

width

int

Yes

Bounding box width

height

int

Yes

Bounding box height

Returns:

BoundingBox2D instance.

Raises:

None.

to_dict​

Signature:

BoundingBox2D.to_dict() -> dict[str, int]

Description:

Converts to a dictionary containing x / y / width / height.

Parameters:

No parameters.

Returns:

dict[str, int].

Raises:

None.