2D/3D bounding box library for Computer Vision
Project description
bbox
bbox
a Python library that is intended to ease the use of 2D and 3D bounding boxes in areas such as Object Detection by providing a set of flexible primitives and functions that are intuitive and easy to use out of the box.
Features
2D Bounding Box
Easily work with bounding boxes using a simple class that abstracts and maintains various attributes.
from bbox import BBox2D
# x, y, w, h
box = BBox2D([0, 0, 32, 32])
# equivalently, in (x1, y1, x2, y2) (aka two point format), we can use
box = BBox2D([0, 0, 31, 31], two_point=True)
print(box.x1, box.y1) # -> 0 0
print(box.x2, box.y2) # -> 31 31
print(box.height, box.width) # -> 32 32
# Syntatic sugar for height and width
print(box.h, box.w) # -> 32 32
Sequence of 2D bounding boxes
Most tasks involve dealing with multiple bounding boxes. This can also be handled conveniently with the BBox2DList
class.
bbl = BBox2DList(np.random.randint(10, 4),
two_point=False)
The above snippet creates a list of 10 bounding boxes neatly abstracted into a convenient object.
Non-maximum Suppression
Need to perform non-maximum suppression? It is as easy as a single function call.
from bbox.utils import nms
# bbl -> BBox2DList
# scores -> list/ndarray of confidence scores
new_boxes = nms(bbl, scores)
Intersection over Union (Jaccard Index)
The Jaccard Index or IoU is a very useful metric for finding similarities between bounding boxes. bbox
provides native support for this.
from bbox.metrics import jaccard_index_2d
box1 = BBox2D([0, 0, 32, 32])
box2 = BBox2D([10, 12, 32, 46])
iou = jaccard_index_2d(box1, box2)
We can even use the Jaccard Index to compute a distance metric between boxes as a distance matrix:
from bbox.metrics import multi_jaccard_index_2d
dist = 1 - multi_jaccard_index_2d(bbl, bbl)
3D Bounding Box
bbox
also support 3D bounding boxes, providing convenience methods and attributes for working with them.
Project details
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
File details
Details for the file bbox-0.8.2.tar.gz
.
File metadata
- Download URL: bbox-0.8.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f81d328408756a140978e368ff6ba6bdf2f75eb28df73168fcf2952c8f1553e0 |
|
MD5 | f0b61375a1e38e2295f156d658629a16 |
|
BLAKE2b-256 | 6a4a984be032f678d185f37fb6637fbf285431d2392e07d34c0b4e8ae8aef327 |
File details
Details for the file bbox-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: bbox-0.8.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ec670d112e4f1bd01f3cca16aa351d0c8dda9aabde682b34ed42315e7f74f0b |
|
MD5 | 4e4496590c83c2d0eac7f8c3cf85de03 |
|
BLAKE2b-256 | fdd2880a376f6bc7721cd6fd2b64b82584b86cc296fb0b13fc2561bcb8c2ab44 |