Light Weight Toolkit for Bounding Boxes
Project description
PyBboxes
Light weight toolkit for bounding boxes providing conversion between bounding box types and simple computations. Supported bounding box types:
- albumentations : Albumentations Format
- coco : COCO (Common Objects in Context)
- fiftyone : FiftyOne
- voc : Pascal VOC
- yolo : YOLO
Installation
Through pip (recommended),
pip install pybboxes
or build from source,
git clone https://github.com/devrimcavusoglu/pybboxes.git
cd pybboxes
python setup.py install
Conversion
You are able to convert from any bounding box type to another.
import pybboxes as pbx
coco_bbox = (1,2,3,4) # COCO Format bbox as (x-tl,y-tl,w,h)
voc_bbox = (1,2,3,4) # Pascal VOC Format bbox as (x-tl,y-tl,x-br,y-br)
pbx.convert_bbox(coco_bbox, from_type="coco", to_type="voc") # (1, 2, 4, 6)
pbx.convert_bbox(voc_bbox, from_type="voc", to_type="coco") # (1, 2, 2, 2)
Some formats require image width and height information for scaling, e.g. YOLO bbox (resulting are round coordinates are rounded to 2 decimals to ease reading).
import pybboxes as pbx
voc_bbox = (1,2,3,4) # Pascal VOC Format bbox as (x-tl,y-tl,x-br,y-br)
pbx.convert_bbox(voc_bbox, from_type="voc", to_type="yolo", image_width=28, image_height=28) # (0.07, 0.11, 0.07, 0.07)
Computation
You can also make computations on supported bounding box formats.
import pybboxes as pbx
coco_bbox = (1,2,3,4) # COCO Format bbox as (x-tl,y-tl,w,h)
voc_bbox = (1,2,3,4) # Pascal VOC Format bbox as (x-tl,y-tl,x-br,y-br)
pbx.compute_area(coco_bbox, bbox_type="coco") # 12
pbx.compute_area(voc_bbox, bbox_type="voc") # 4
Tests
To tests simply run.
python tests/run_tests.py
Code Style
To check code style,
python tests/run_code_style.py check
To format codebase,
python tests/run_code_style.py format
License
Licensed under the 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
File details
Details for the file pybboxes-0.0.2.tar.gz
.
File metadata
- Download URL: pybboxes-0.0.2.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 291c665a857392d1b39b4f9d47260d61d696ce32c3c2cb6b6800b0886a09eb6f |
|
MD5 | b0a7b87e4a7548b2ffd7fcab557a1f79 |
|
BLAKE2b-256 | 9bcfc2ac454b870a55278ccc107ab4dafc84d7e5a7819061ac15c60ceee69401 |
File details
Details for the file pybboxes-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pybboxes-0.0.2-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ecb9982aa55c1eee851947daea1a788dec3525abd8d154891df13000092fbf4 |
|
MD5 | c6bdf956c36a6c4d243583769ce08090 |
|
BLAKE2b-256 | ac705eaae00496d64b7ac2619ae937f204b5d3d3620713597f4f627c27c34dca |