SimpleBBox
Functions for bounding box processing.
In many computer vision tasks a concept of a bounding box is used. In python bounding boxes are often represented as lists, tuples or numpy arrays of 4 elements. However there is no standard representation and different formats are used. Some formats are listed below.
(min x, min y, width, height) or (left, top, width, height)
(min x, min y, max x, max y) or (left, top, bottom, right)
(center x, center y, width, height)
The coordinates can represent either
relative position in the image dimensions. Then x takes values from 0..1 for pixels inside the image
or absolute position in pixel (either integer or floating point numbers)
This package contains utility functions to convert between those formats.
Basic assumptions
Simple data structures are used: lists, tuples, numpy arrays. They fit well to the output of the deep learning models. Speed and simplicity is chosen over type and range safety. For better type safety one can use alternative implementations with classes. See alternatives page of the docs.
Conversion operations between integer and float numbers are sometimes cumbersome. We are trying to keep it aligned with standard python. For example rounding of float numbers while computing a center of a bounding box is done using Round_half_to_even algorithm.
Several functions for different handing of floats/ints are provided for the same operation. E.g. cxcywh_to_x0y0wh_float, cxcywh_to_x0y0wh_int
In simple use cases like a single conversion from one format to another one can probably chose any of the versions for float conversions. More thorough selection is needed in case of multiple back and forth conversions.
Installation
pip install simplebbox
Usage example
Examples of conversions:
from simplebbox.array import x0y0wh_to_x0y0x1y1, x0y0x1y1_to_x0y0wh
# convert bbox represented as list in ltwh format:
x0y0wh_to_x0y0x1y1([100, 200, 10, 20]) # [100, 200, 110, 220]
# and convert it back:
x0y0x1y1_to_x0y0wh([100, 200, 110, 220]) # [100, 200, 10, 20]
Notes
Free software: MIT license
Documentation: https://simplebbox.readthedocs.io.
History
0.0.9 (2021-03-02)
implementation of batch processing for torch and numpy
simplification of float/int conversions, merged some tests for array/tensor implementations
reworked a conversion with integer divisions
Interfaces (and names) of array processing functions have changed. This is a breaking change.
0.0.7 (2020-12-17)
Added conversion between relative and absolute coordinates.
0.0.6 (2020-12-17)
Implemented basic conversions. Updated documentation, tests.
0.0.1 (2020-12-16)
First release on PyPI.
Metadata
Release files for simplebbox 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplebbox-0.0.10.tar.gz | 14.5 kB | Without provenance | Details for simplebbox-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| simplebbox-0.0.10-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for simplebbox-0.0.10-py2.py3-none-any.whl |
Total release size: 21.7 kB
Release files / simplebbox-0.0.10.tar.gz
| Download URL | simplebbox-0.0.10.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29bbb4799d189357b91bb094eef3a7b2153d36466e5f44236db2599c66fdf383
|
|
BLAKE2b-256 checksum How to use checksums |
7fcc99e8cafbd142c2fdfbaf48bf9db402d9a1bf76b3ca291376edc3856303dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3
|
Release files / simplebbox-0.0.10-py2.py3-none-any.whl
| Download URL | simplebbox-0.0.10-py2.py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c7f0f57e7b309008a4674fc9c93ed134b437e9073f90ab518522fcbf2427fbbe
|
|
BLAKE2b-256 checksum How to use checksums |
33519c9dd54f089c30c08957b6356cdab5e49fbb05bce7bc7e9a9ab2171f5c0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3
|
Security for simplebbox 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.