PowerBoxesrs
Powerboxes is a package containing utility functions for transforming bounding boxes and computing metrics.
Installation
Functions available
Note: all functions expect boxes in xyxy format (top left and bottom right corners), except box conversion and rotated box functions.
All core functions have a _slice variant operating on flat &[N] slices. ndarray wrappers are available behind the ndarray feature (enabled by default).
Box Transformations and utilities
box_areas: Compute the area of list of boxesbox_convert: Convert a box from one format to another. Supported formats arexyxy,xywh,cxcywhremove_small_boxes: Remove boxes with area smaller than a thresholdmasks_to_boxes: Convert a mask to a list of boxes
Box Metrics
iou_distance: Compute the intersection over union matrix of two sets of boxesparallel_iou_distance: Compute the intersection over union matrix of two sets of boxes in parallelgiou_distance: Compute the generalized intersection over union matrix of two sets of boxesparallel_giou_distance: Compute the generalized intersection over union matrix of two sets of boxes in paralleldiou_distance: Compute the distance intersection over union matrix of two sets of boxestiou_distance: Compute the tracking intersection over union matrix of two sets of boxes
Rotated Box Metrics
Rotated boxes use (cx, cy, w, h, angle) format where angle is in degrees.
rotated_iou_distance: Compute IoU distance for rotated boxesrotated_giou_distance: Compute GIoU distance for rotated boxesrotated_tiou_distance: Compute tracking IoU distance for rotated boxes
Box NMS
nms: Non-maximum suppression, returns the indices of the boxes to keeprtree_nms: Non-maximum suppression using an R-tree for sub-quadratic complexity
Drawing
draw_boxes: Draw bounding boxes on a CHW image tensor
Usage
See the documentation for more details.
Slice-based API (no ndarray dependency)
All core functions have a _slice variant that operates on flat &[N] slices. This avoids coupling to a specific ndarray version (#60).
To use powerboxesrs without ndarray:
[]
= { = "0.3", = false }
use iou_distance_slice;
// Flat slice: [x1, y1, x2, y2, ...] with num_boxes
let boxes1 = vec!;
let boxes2 = vec!;
let iou = iou_distance_slice;
ndarray API (default)
With the ndarray feature (enabled by default), you get wrappers that accept ArrayView2 directly. The ndarray dependency is flexible (>=0.15, <=0.16) to minimize version conflicts.
use iou_distance;
use array;
let boxes1 = array!;
let boxes2 = array!;
let iou = iou_distance;