Easy Bbox
Easy Bbox is a Python package designed to simplify bounding box operations. It provides a comprehensive set of tools for manipulating bounding boxes in various coordinate formats, including Pascal VOC, COCO, YOLO and Albumentations. The package supports transformations, geometric operations, and conversions, making it a versatile tool for computer vision tasks.
Features
- Pydantic model: Bbox objects are Pydantic models.
- Multiple Coordinate Formats: Supports Pascal VOC, COCO, YOLO and Albumentation formats.
- Transformations: Shift, scale, expand, and pad bounding boxes.
- Geometric Operations: Calculate intersections, unions, and IoU (Intersection over Union).
- Conversions: Convert between different coordinate formats.
- Utility Functions: Includes Non-Maximum Suppression (NMS) for filtering overlapping bounding boxes.
Installation
Easy Bbox is published as a python package and can be pip installed.
pip install easy-bbox
Usage
Creating a Bounding Box
You can create a bounding box using the Bbox class. The bounding box is stored in Pascal VOC format, which is top-left, bottom-right with a top-left origin (PIL coordinate system), but can be instantiated from different formats.
from easy_bbox import Bbox
# All of the following Bbox are equal
# Create a bounding box using top-left and bottom-right coordinates
bbox = Bbox(left=10, top=20, right=30, bottom=40)
# Instantiate from a sequence in Pascal VOC format
bbox = Bbox.from_pascal_voc([10, 20, 30, 40])
bbox = Bbox.from_tlbr([10, 20, 30, 40])
bbox = Bbox.from_xyxy([10, 20, 30, 40])
bbox = Bbox.from_list([10, 20, 30, 40])
# Create a bounding box using top-left and width-height coordinates (COCO format)
bbox = Bbox.from_tlwh((10, 20, 20, 20))
bbox = Bbox.from_coco((10, 20, 20, 20))
# Create a bounding box using center and width-height coordinates
bbox = Bbox.from_cwh((20, 30, 20, 20))
Transformations
Easy Bbox provides several methods for transforming bounding boxes:
Conversions
Easy Bbox provides methods for converting between different coordinate formats:
# Convert to Top-Left, Bottom-Right format
tlbr = bbox.to_tlbr() # Same as `.to_pascal_voc()`, `.to_xyxy()`
# Convert to Top-Left, Width-Height format
tlwh = bbox.to_tlwh() # Same as `.to_coco()`
# Convert to Center, Width-Height format
cwh = bbox.to_cwh()
# Convert to normalized Top-Left, Bottom-Right format
norm_tlbr = bbox.to_norm_tlbr(img_w=100, img_h=100) # Same as `.to_albu(...)`
# Convert to normalized Top-Left, Width-Height format
norm_tlwh = bbox.to_norm_tlwh(img_w=100, img_h=100)
# Convert to normalized Center, Width-Height format
norm_cwh = bbox.to_norm_cwh(img_w=100, img_h=100) # Same as `.to_yolo(...)`
# Convert to polygon format
polygon = bbox.to_polygon()
Utility
Easy Bbox includes utility functions for common tasks:
from easy_bbox import nms
# Get the minimal englobing bbox
union = bbox1.union(bbox2) # same as bbox1 | bbox2
# Get the intersection
inter = bbox1.intersection(bbox2) # same as bbox1 & bbox2
# Calculate the IoU of two bboxes
iou = bbox1.iou(bbox2)
# Check if two bboxes are overlapping
overlap = bbox1.overlaps(bbox2)
# Check if a bbox contains a point
is_inside = bbox1.contains_point((5, 10))
# Calculate the distance from a point to a bbox
dist = bbox1.distance_to_point((5, 10))
# Perform Non-Maximum Suppression
selected_bboxes = nms(bboxes, scores, iou_threshold=0.5)
Metadata
Release files for easy-bbox 1.0.7
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 |
|---|---|---|---|---|
| easy_bbox-1.0.7.tar.gz | 15.8 kB | Without provenance | Details for easy_bbox-1.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| easy_bbox-1.0.7-py3-none-any.whl | Python 3 | none | any | Details for easy_bbox-1.0.7-py3-none-any.whl |
Total release size: 26.5 kB
Release files / easy_bbox-1.0.7.tar.gz
| Download URL | easy_bbox-1.0.7.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f366ef33b1e5adc8bcbd4c038fb9b0236ac8583ce8bf55d99ed25b0fd853ab8c
|
|
BLAKE2b-256 checksum How to use checksums |
bcea55e790516a0b94b50254f3d55fb9570c2a684e001b6610d9420bc5f40a57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Release files / easy_bbox-1.0.7-py3-none-any.whl
| Download URL | easy_bbox-1.0.7-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72f1e94df867a2d39494dc4da6abe2035096d2c83edb383f385d48404a6fc3af
|
|
BLAKE2b-256 checksum How to use checksums |
0b80ea6a99cfbb8c2d1dfcbe3cca30b8ee664927f9772d5ab096a72dc28025b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.11
|
Security for easy-bbox 1.0.7
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.