pub struct BBoxXYXY<TSpace> {
pub min: Coord<TSpace>,
pub max: Coord<TSpace>,
}Expand description
An axis-aligned bounding box in XYXY format (xmin, ymin, xmax, ymax).
The TSpace parameter should be either Pixel or
Normalized, ensuring type safety across
coordinate spaces.
Note: This type does NOT enforce that min < max in the constructor, allowing “malformed” boxes to exist in the IR. This is intentional - validation should catch and report these issues rather than preventing them from being represented.
Fields§
§min: Coord<TSpace>§max: Coord<TSpace>Implementations§
Source§impl<TSpace> BBoxXYXY<TSpace>
impl<TSpace> BBoxXYXY<TSpace>
Sourcepub fn new(min: Coord<TSpace>, max: Coord<TSpace>) -> Self
pub fn new(min: Coord<TSpace>, max: Coord<TSpace>) -> Self
Creates a new bounding box from min and max coordinates.
Sourcepub fn from_xyxy(xmin: f64, ymin: f64, xmax: f64, ymax: f64) -> Self
pub fn from_xyxy(xmin: f64, ymin: f64, xmax: f64, ymax: f64) -> Self
Creates a new bounding box from explicit coordinates.
Sourcepub fn width(&self) -> f64
pub fn width(&self) -> f64
Returns the width of the bounding box.
May be negative if the box is malformed (xmax < xmin).
Sourcepub fn height(&self) -> f64
pub fn height(&self) -> f64
Returns the height of the bounding box.
May be negative if the box is malformed (ymax < ymin).
Sourcepub fn area(&self) -> f64
pub fn area(&self) -> f64
Returns the area of the bounding box.
May be negative if the box is malformed.
Sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns true if all coordinates are finite (not NaN or infinite).
Sourcepub fn is_ordered(&self) -> bool
pub fn is_ordered(&self) -> bool
Returns true if the box is properly ordered (min <= max for both axes).
Source§impl<TSpace> BBoxXYXY<TSpace>
Conversion utilities for different bbox formats.
impl<TSpace> BBoxXYXY<TSpace>
Conversion utilities for different bbox formats.
Sourcepub fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
pub fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
Converts from XYWH format (x, y, width, height) where (x, y) is the top-left corner.
This is the format used by COCO annotations.