Skip to main content

Stylized OpenCV rectangle and frame drawing helpers for detection overlays.

Project description

🖼️ drawcv — Stylish Bounding Boxes for OpenCV

drawcv style gallery

PyPI version MIT License Python 3.8+ OpenCV compatible

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-python
  • numpy

📄 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.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-style)
  3. Commit your changes (git commit -m 'Add new frame style')
  4. 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

drawcv-0.1.3.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drawcv-0.1.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file drawcv-0.1.3.tar.gz.

File metadata

  • Download URL: drawcv-0.1.3.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

Hashes for drawcv-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9ed113b058d9cf3a2e3c6a39a2fa4b76c1d7a0c33346f5c33d910cca75f08b18
MD5 f2805051e1471794809b04dec767cba8
BLAKE2b-256 8f5a6d971e7478522aad764e73232298fa95747ff5618b128872e697757f69cf

See more details on using hashes here.

File details

Details for the file drawcv-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: drawcv-0.1.3-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

Hashes for drawcv-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 209874fcd3e9760f64d8fe127fa7360d9a19bddbf3e180500c58a1f984a58d74
MD5 5ad1870912ba139502327c32668ca9b4
BLAKE2b-256 e9c67f0b3b47113632ee9b560804b3db67379d5bb64011c9945774c4f3a29c54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page