Introduction to bbox-visualizer
bbox-visualizer
is a Python package designed to simplify the process of drawing bounding boxes around objects in images. This package is particularly useful for those working on object detection and recognition tasks, where annotating images is a critical step. It alleviates the burden of manual calculations required for properly placing and labeling bounding boxes, by offering convenient pre-defined functions.
Key Features
- Ease of Use: The package allows users to draw bounding boxes using the typical
(xmin, ymin, xmax, ymax)
coordinate format with ease. - Variety of Visualizations: It provides several visualization options, including bounding boxes with labels positioned in different styles such as on top, inside, or resembling a flag.
- Multiple Annotations: Users can annotate multiple objects within a single image using provided functions, ensuring efficiency in processing batch images.
Installation
To begin using bbox-visualizer
, simply install it via pip:
pip install bbox-visualizer
Basic Usage
To use the package, first import it in your Python script:
import bbox_visualizer as bbv
Once imported, users can utilize various functions provided by bbox-visualizer
to draw and label bounding boxes in different styles on their images.
Visualization Options
Here are some capabilities offered by the package:
- Bounding Box with Label on Top: Draws a rectangle around the object, with the label placed above the box.
img = bbv.draw_rectangle(img, bbox) img = bbv.add_label(img, label, bbox, top=True)
- Bounding Box with Label Inside: Places the label within the boundaries of the bounding box.
img = bbv.draw_rectangle(img, bbox) img = bbv.add_label(img, label, bbox, top=False)
- Bounding Box with T Label: Adds a "T" style label that sits inside the bounding box.
img = bbv.draw_rectangle(img, bbox) img = bbv.add_T_label(img, label, bbox)
- Flag Style Label: Displays a label that resembles a flag, with a pole starting inside the object.
img = bbv.draw_flag_with_label(img, label, bbox)
- Opaque Bounding Box: Creates an opaque box with a label, providing more emphasis on the labeled object.
img = bbv.draw_rectangle(image, bbox, is_opaque=True) img = bbv.add_label(img, label, bbox, draw_bg=False, top=False)
Handling Multiple Annotations
Although bbox-visualizer
includes optional functions to process multiple bounding boxes and labels in a single call, for greater control over the output, users can loop through their items, leveraging singular annotations functions:
- Multiple Bounding Boxes:
img = bbv.draw_multiple_rectangles(img, bboxes) img = bbv.add_multiple_labels(img, labels, bboxes)
- Flags for Multiple Items:
img = bbv.draw_multiple_flags_with_labels(img, labels, bboxes)
- Multiple T Labels:
img = bbv.draw_multiple_rectangles(img, bboxes) img = bbv.add_multiple_T_labels(img, labels, bboxes)
Here, bboxes
and labels
are expected to be lists that correspond to each object annotated within the image.
License and Acknowledgments
bbox-visualizer
is open-source software available under the MIT License, allowing for broad usage and contributions. The project was initially created using Cookiecutter with the audreyr/cookiecutter-pypackage
template, showcasing the combined efforts of its contributors.
For detailed documentation, potential users and developers can visit the official documentation site.