Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/varunagrawal/bbox
Python library for 2D/3D bounding boxes
https://github.com/varunagrawal/bbox
3d-bounding-boxes bounding-boxes computer-vision computer-vision-tools
Last synced: 3 months ago
JSON representation
Python library for 2D/3D bounding boxes
- Host: GitHub
- URL: https://github.com/varunagrawal/bbox
- Owner: varunagrawal
- License: mit
- Created: 2018-06-01T00:36:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-03T21:21:06.000Z (about 1 year ago)
- Last Synced: 2024-05-08T08:32:09.063Z (6 months ago)
- Topics: 3d-bounding-boxes, bounding-boxes, computer-vision, computer-vision-tools
- Language: Python
- Homepage: https://varunagrawal.github.io/bbox/
- Size: 5.84 MB
- Stars: 98
- Watchers: 8
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://travis-ci.org/varunagrawal/bbox.svg?branch=master)](https://travis-ci.org/varunagrawal/bbox)
[![codecov](https://codecov.io/gh/varunagrawal/bbox/branch/master/graph/badge.svg)](https://codecov.io/gh/varunagrawal/bbox)[![PyPI version](https://badge.fury.io/py/bbox.svg)](https://badge.fury.io/py/bbox)
![PyPI format](https://img.shields.io/pypi/format/bbox.svg)
![](https://img.shields.io/pypi/status/bbox.svg)
![](https://img.shields.io/pypi/pyversions/bbox.svg)![](https://img.shields.io/pypi/l/bbox.svg)
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/varunagrawal)## Features
### 2D Bounding Box
Easily work with bounding boxes using a simple class that abstracts and maintains various attributes.
```python
from bbox import BBox2D, XYXY# 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 boxesMost tasks involve dealing with multiple bounding boxes. This can also be handled conveniently with the `BBox2DList` class.
```python
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.
```python
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.
```python
from bbox.metrics import jaccard_index_2dbox1 = 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:
```python
from bbox.metrics import multi_jaccard_index_2ddist = 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.