Home
Softono
bbox-visualizer

bbox-visualizer

Open source MIT Python
413
Stars
36
Forks
0
Issues
5
Watchers
1 month
Last Commit

About bbox-visualizer

Make drawing and labeling bounding boxes a piece of cake

Platforms

Web Self-hosted

Languages

Python

bbox-visualizer

Documentation Status Test License: MIT Ruff PyPI version Downloads

This package helps users draw bounding boxes around objects, without doing the clumsy math that you'd need to do for positioning the labels. It also has a few different types of visualizations you can use for labeling objects after identifying them.

The bounding box points are expected in the format: (xmin, ymin, xmax, ymax)

Installation:

pip install bbox-visualizer

Usage:

import bbox_visualizer as bbv

cover

Photos by Joshua Earle, Jonas Weckschmied and Sherzod Max on Unsplash.

image function
bbox with label on top img = bbv.draw_box(img, bbox)
img = bbv.add_label(img, label, bbox, top=True)
bbox with T label img = bbv.draw_box(img, bbox)
img = bbv.add_T_label(img, label, bbox)
label with flag img = bbv.draw_flag_with_label(img, label, bbox)
bbox with label inside img = bbv.draw_box(img, bbox)
img = bbv.add_label(img, label, bbox, top=False)
label with opaque overlay img = bbv.draw_box(image, bbox, is_opaque=True)
img = bbv.add_label(img, label, bbox, draw_bg=False, top=False)
multiple bbox img = bbv.draw_multiple_boxes(img, bboxes)
img = bbv.add_multiple_labels(img, labels, bboxes)
multiple flags img = bbv.draw_multiple_flags_with_labels(img, labels, bboxes)
multiple T bbox img = bbv.draw_multiple_boxes(img, bboxes)
img = bbv.add_multiple_T_labels(img, labels, bboxes)

Note: The functions draw_rectangle and draw_multiple_rectangles are also available as aliases for draw_box and draw_multiple_boxes respectively. Both naming conventions work identically.

There are optional functions that can draw multiple bounding boxes and/or write multiple labels on the same image, but it is advisable to use the above functions in a loop in order to have full control over your visualizations.

  • bbv.draw_multiple_boxes(img, bboxes)
  • bbv.add_multiple_labels(img, labels, bboxes)
  • bbv.add_multiple_T_labels(img, labels, bboxes)
  • bbv.draw_multiple_flags_with_labels(img, labels, bboxes)

bboxes and labels are lists in the above examples.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.