Simple bounding box operations
Simple operations over bounding boxes.
Bounding boxes are represented in XYWH format where
(X,Y) is coordinate of top-left corner, and
(W,H) its size. I.e.
bb = [0,0,64,16] represents a rectangle of size 64x16 located at coordinate
(0,0). The units are always abstract - the interpretation is left for the user (usually pixels are used).
The package defines several common operations - resize, aspect ratio changes, randomization.
import bbx bb = (-5,-5,10,10) # Center at (0,0) bb = bbx.set_aspect_ratio(bb, 2, bbx.KEEP_WIDTH) print(bb) # Prints [[-5.0, -10.0, 10, 20]]
The package is in PyPI so just use
pip install bbx
Bounding boxes are defined in x,y,w,h format, but they can hold any additional information (e.g. ignore flag). All functions always work on first four elements.
bbx.set_aspect_ratio(bbs, ar, type)
Set aspecr ratio
ar to all bounding boxes in
type method. The
type can be one of:
For unknown type, the function raises
ratio without moving center. The
ratio can be:
- scalar - all boxes are resized by the same factor
- tuple of two scalars - resize all boxes with different scale for width and height
This code is published under MIT License
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size bbx-0.0.4-py3-none-any.whl (5.2 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size bbx-0.0.4.tar.gz (5.1 kB)||File type Source||Python version None||Upload date||Hashes View|