Simple bounding box operations
Project description
Package bbx
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]]
Installation
The package is in PyPI so just use pip
pip install bbx
Documentation
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 bbs
using type
method. The type
can be one of:
bbx.EXPAND
bbx.SHRINK
bbx.KEEP_WIDTH
bbx.KEEP_HEIGHT
bbx.KEEP_AREA
For unknown type, the function raises NotImplementedError
bbx.resize(bbs, scale)
Resize bbs
by 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
bbx.scale
bbx.move
bbx.center
bbx.overlap
bbx.dist_matrix
bbx.nms
bbx.groups
bbx.randomize
TODOs
- Documentation
- Tests
License
This code is published under MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bbx-0.0.3.dev1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d931a6ae5697d652db06488f9f7d14934e5337b3c903cee6cb3cff3644830a4 |
|
MD5 | eac816ab907af77fc1a2b3ce38dc03d6 |
|
BLAKE2b-256 | 77208c545ecba5124b2e223fef795e7847443d0bbc787d2e62072fdcae552f6d |