Skip to main content

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.

Build Status codecov

PyPI version PyPI format

Say Thanks!

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], mode=XYXY)

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),
                 mode=XYWH)

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

bbox-0.8.3.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bbox-0.8.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file bbox-0.8.3.tar.gz.

File metadata

  • Download URL: bbox-0.8.3.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for bbox-0.8.3.tar.gz
Algorithm Hash digest
SHA256 f98c121ea6a3b95da1977e6cc154609b66c674467b242f69ca8f17841fcbc03c
MD5 f205a75dc210b677fc56f60b704fea94
BLAKE2b-256 b37eb6c79d2e72d9a2b8c9b2526ed5df3e155c8c675901a77d8c122c3af00738

See more details on using hashes here.

File details

Details for the file bbox-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: bbox-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.32.1 CPython/3.7.2

File hashes

Hashes for bbox-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2eb02a852af56a86e7ede4c3c74484b96c7f077e343e91d80572a8fc4fa9c8
MD5 6e56b20b66701b12150484104d783038
BLAKE2b-256 5f5cd0c7fb5dd072257db79028eded7e45decc9b6c2e660785613dfacbc37eb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page