Stylized OpenCV rectangle and frame drawing helpers for detection overlays.
Project description
🖼️ drawcv — Stylish Bounding Boxes for OpenCV
Drop-in upgrade for
cv2.rectangle()— turn plain bounding boxes into polished, production-ready detection overlays with a single function call.
✨ What is drawcv?
drawcv is a lightweight Python library that replaces OpenCV's bare-bones bounding rectangles with a collection of modern, styled frames ready for demos, dashboards, and detection pipelines. It works directly on numpy arrays using OpenCV under the hood, so it fits seamlessly into any existing workflow.
One line change. Dramatically better visuals.
📦 Installation
pip install drawcv
🚀 Quick Start
import cv2
from drawcv import drawcv
image = cv2.imread("resource/test.png")
drawcv(
image=image,
style_id="pro-clean-blue", # style name or index (0, 1, 2…)
coords=(80, 60, 280, 220), # (x1, y1, x2, y2)
)
cv2.imwrite("output.jpg", image)
🔁 Migration from Plain OpenCV
If you're already using cv2.rectangle, switching takes seconds:
Before
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
After
from drawcv import drawcv
drawcv(
image=image,
style_id="pro-clean-blue",
coords=(x1, y1, x2, y2),
)
With Optional Color & Line Width Override
drawcv(
image=image,
style_id="futuristic-hud",
coords=(x1, y1, x2, y2),
color=(255, 255, 255), # BGR color override
line_width=1,
)
🎨 Available Styles
List all available styles programmatically:
from drawcv import list_visionframe_styles
styles = list_visionframe_styles()
print(styles)
Styles can be referenced by name (e.g. "futuristic-hud") or by index (e.g. 0, 1, 2).
Generate the Style Gallery
import cv2
from drawcv import create_visionframe_gallery
gallery = create_visionframe_gallery()
cv2.imwrite("resource/visionframe_styles_gallery.png", gallery)
🔧 API Reference
drawcv(image, style_id, coords, color=None, line_width=None)
| Parameter | Type | Description |
|---|---|---|
image |
np.ndarray |
OpenCV image (BGR, modified in-place) |
style_id |
str or int |
Style name or index from list_visionframe_styles() |
coords |
tuple |
Bounding box as (x1, y1, x2, y2) |
color |
tuple (optional) |
BGR color override (B, G, R) |
line_width |
int (optional) |
Line thickness override |
list_visionframe_styles() → list[str]
Returns a list of all available style names.
create_visionframe_gallery() → np.ndarray
Generates a preview gallery image of all available styles.
🏗️ Project Structure
visionframe/
├── src/ # Library source code
├── tests/ # Pytest test suite
├── resource/ # Sample images and gallery output
├── setup.py
├── pyproject.toml
└── requirements-dev.txt
🛠️ Local Development
# Create and activate virtual environment
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/macOS
# Install in editable mode with dev dependencies
pip install -e .[dev]
Run Tests
pytest
Build Package
python -m build
📋 Requirements
- Python 3.8+
opencv-pythonnumpy
📄 License
This project is licensed under the MIT License.
🤝 Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request for new styles, bug fixes, or improvements.
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-style) - Commit your changes (
git commit -m 'Add new frame style') - Push and open a Pull Request
Made with ❤️ for the computer vision community
Project details
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 drawcv-0.1.4.tar.gz.
File metadata
- Download URL: drawcv-0.1.4.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83d22186b602dc1ba116f38f9cc814bb58b4e6c82a11e73932f1a2680a633dd2
|
|
| MD5 |
bf20ef33e5ebc5e3e441ae68d3c8e749
|
|
| BLAKE2b-256 |
a3918736e8fe2f048ff9f0955cdf398bb5632fd73d165a7f4a1a31e386e2784e
|
File details
Details for the file drawcv-0.1.4-py3-none-any.whl.
File metadata
- Download URL: drawcv-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27c30d69f7eaf9dd6cec57c7eb82e6bf680afae41e4f2c95394b8014b461b436
|
|
| MD5 |
750f7a7f541492a1c95f255ddf0a3410
|
|
| BLAKE2b-256 |
2f894923a0ac6c62ff4224e0043a177288e3d27ce18e194cb6dac3dd4104fdd9
|