Skip to content

About

Real-time virtual painting application using OpenCV-based color detection and webcam tracking.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🎨 Virtual Painter

A real-time virtual painting application built with Python and OpenCV that allows you to draw in the air using a colored pen or marker in front of a webcam.

The application detects the marker based on its color, tracks its position in real time, and renders the detected movement as a virtual drawing on the video feed.

✨ Features

  • Real-time webcam-based tracking
  • Color-based object detection using HSV color space
  • Detection of multiple marker colors
  • Contour-based object localization
  • Real-time virtual drawing
  • Adjustable camera resolution
  • Simple keyboard control to exit the application

🧠 How It Works

The application captures live webcam frames and converts them from BGR to HSV color space for color-based segmentation. Predefined HSV ranges are used to isolate the supported marker colors.

Contours are detected from the resulting masks, and the position of the detected marker is tracked in real time. The tracked coordinates are then rendered as colored points on the webcam feed to create the virtual painting effect.

Webcam Frame
     ↓
BGR → HSV
     ↓
Color Segmentation
     ↓
Contour Detection
     ↓
Marker Position Tracking
     ↓
Virtual Drawing

🛠️ Tech Stack

  • Python
  • OpenCV
  • NumPy
  • Computer Vision
  • HSV Color Space
  • Contour Detection

🚀 Getting Started

Prerequisites

  • Python 3.x
  • A working webcam

Installation

Clone the repository:

git clone https://github.com/hetpatel4902/virtual-painter.git
cd virtual-painter

Install the required dependencies:

pip install opencv-python numpy

Run the Application

python virtualPainter.py

The webcam window will open and the application will begin detecting the configured marker colors.

Hold a colored pen or marker in front of the webcam and move it through the camera frame to draw virtually.

Press q to exit the application.

🎨 Supported Colors

The application is configured to detect three marker colors:

  • Pink
  • Yellow
  • Blue

The HSV thresholds and corresponding drawing colors can be modified in virtualPainter.py.

⚙️ Customization

Marker detection can be customized by modifying the HSV ranges in virtualPainter.py.

Additional colors can be supported by defining new HSV ranges and their corresponding drawing colors.

📁 Project Structure

virtual-painter/
│
├── virtualPainter.py
└── README.md

📌 Project Background

Virtual Painter was developed as an early exploration of computer vision and real-time image processing using OpenCV.

The project demonstrates how webcam input, color segmentation, contour detection, and coordinate tracking can be combined to create an interactive computer-vision application.

About

Real-time virtual painting application using OpenCV-based color detection and webcam tracking.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages