A Python-based virtual painting app that uses your hand gestures (tracked by MediaPipe) as a brush, powered by OpenCV for real-time webcam drawing. You can select colors, switch brush types, erase, and even clear the canvas β all using just your fingers!
-
Hand Tracking using MediaPipe
-
Color Selection via gesture-based palette
-
Three Brush Types:
- Normal
- Spray
- Calligraphy
-
Eraser Tool
-
Clear Canvas Gesture
-
Brush Toggle Gesture
-
Real-time Drawing with Webcam
-
Save Drawing with a keypress
- Python 3
- OpenCV
- MediaPipe
- NumPy
- Clone this repository
git clone https://github.com/evitabarboza/Virtual-Painter-Using-Hand-Tracking
.git
cd Virtual-Painter-Using-Hand-Tracking- Create virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install opencv-python mediapipe numpypython app.py- A webcam window will open.
- Use hand gestures to draw and control the interface (explained below).
| Gesture | Action |
|---|---|
| Index finger + Middle up | Select color from top palette |
| Only Index finger up | Draw on the canvas |
| All 5 fingers up | Clear the entire canvas |
| Index + Middle + Ring fingers up | Toggle brush type (Normal β Spray β Calligraphy) |
| Thumb up | Not used |
-
Top Palette: Select from 8 predefined colors (last is Eraser).
-
Brush Types:
- Normal: Basic line
- Spray: Simulated spray effect using random noise
- Calligraphy: Elliptical strokes like a flat nib pen
-
Brush Size: Fixed size (can be modified in code)
-
Eraser: Last palette color (black), larger thickness
-
Save Drawing: Press
skey to save your artwork -
Quit Application: Press
q
Your saved drawing will be stored as:
my_virtual_painting.png
Virtual-Painter-Using-Hand-Tracking/
β
βββ app.py # Main Python script
βββ README.md # This file
- Change brush thickness: modify
brush_thicknessanderaser_thickness. - Add more brush styles or gestures.
- Use dynamic thickness via finger distance.
- Extend for multiple hand support.
This project is open source under the MIT License.
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
Evita Barboza
Feel free to reach out at [email protected].