Library for drawing labeled bounding boxes / bounding polygons
Project description
bbdraw
Library for drawing labeled bounding boxes / bounding polygons
Example image showing labeled bounding boxes and bounding polygons
Basically, a small wrapper around the python pillow library that combines drawing boxes and writing labels into one simple function call:
corners = [(650, 290), (715, 335)] image = bbdraw.rectangle(image, corners, text="cactus", color="red")
Installation
Needs python >= 3.5
pip3 install bbdraw
Usage
from PIL import Image
import bbdraw
image = Image.open("example.jpg")
# box/rectangle is given by two corners
# either as list of tuples [(x0, y0), (x1, y1)] or flat list [x0, y0, x1, y1]
corners = [(650, 290), (715, 335)]
image = bbdraw.rectangle(image, corners, text="cactus", color="red")
# polygon is given by list of vertices
# either as list of tuples [(x0, y0), (x1, y1), (x2, y2), ...]
# or as flat list [x0, y0, x1, y1, x2, y2, ...]
vertices = [(440, 360), (400, 265), (525, 195), (590, 280), (520, 360)]
image = bbdraw.polygon(image, vertices, text="shrub", color="green")
# use in_place=True to directly draw on the input image, instead of making a copy
corners = [(1080, 350), (1180, 285)]
bbdraw.rectangle(image, corners, text="cactus", color="red", in_place=True)
image.save("example_out.jpg")
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bbdraw-0.1.tar.gz.
File metadata
- Download URL: bbdraw-0.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7226a732afc79026addaa0c9178f4a16528fbf982f237ade0133472ab5af7d9
|
|
| MD5 |
2bbfdbc3459dbace64c296d1092040de
|
|
| BLAKE2b-256 |
9739b2709c79fca58602f0ada917d9329edff35ca0878a9ca73036e6f75d6c28
|
File details
Details for the file bbdraw-0.1-py3-none-any.whl.
File metadata
- Download URL: bbdraw-0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1627fec48d6b2cea8258c98036405c41c24d191c295f74bf28bb6ea25c2a9cc3
|
|
| MD5 |
0463332a5b0d0300a83299633f15a4dc
|
|
| BLAKE2b-256 |
508d31e5650acf2f07320e4c07b3f28cd0ff87dbce88ad5e04a39d5652c6cc2e
|