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.5.tar.gz (18.4 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.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: drawcv-0.1.5.tar.gz
  • Upload date:
  • Size: 18.4 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.5.tar.gz
Algorithm Hash digest
SHA256 e4e8e768da6bba9e7d2020d53979ffe9553fb4a7419c1938a86a5b0d4e3d7066
MD5 347bb7b0acb47706837e5e8a4d8d0b92
BLAKE2b-256 a5335125143f95a3a47032a4bb3ed4190351517ffe1f19c6c192cdcf4f70e07a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: drawcv-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6156ad80a7a6b937c6d717b455f26382d236a16878fd6c0d177d13d2cee5c79d
MD5 ac4fbe380663e696eea4fed97ff49950
BLAKE2b-256 2a79a70a9db1b8b6cba4745843fd6901b556d744d1b947c36806c7eb833ff73d

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