A webcam-based virtual painting application. Hold a colored object in front of your camera and use it as a drawing tool on a virtual canvas overlaid on the live feed.
- Python 3.10+
- Webcam
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS / Linux
pip install -r requirements.txtpython main.py- Launch the app. The camera feed appears on the right panel, the canvas on the left.
- Click Set Tracking Color... in the status bar and click on your tracking object in the calibration dialog to sample its color.
- Adjust tolerance as needed, then save. The app begins tracking the object immediately.
- Move the object in front of the camera to draw on the canvas.
- HSV color tracking - click-to-sample calibration with tolerance and advanced H/S/V sliders
- Virtual toolbar - semi-transparent overlay at the top of the camera feed; hover a tool for 0.8 s to select it
- 5 drawing colors - customizable by re-clicking the active swatch
- 3 brush sizes - Small, Medium, Large
- Eraser - fills with the canvas background color
- Undo / Redo - up to 50 steps
- Canvas background color - any color; compositing adapts automatically
- Hold Space to pause drawing - prevents accidental strokes
- Detection rectangle - optional bounding box overlay on the tracked object
- Save canvas - PNG or JPG, timestamped filename by default
- Persistent settings - active color, size, background, and calibration survive restarts
| Action | Shortcut |
|---|---|
| Color 1 - 5 | 1 2 3 4 5 |
| Brush Small | J |
| Brush Medium | K |
| Brush Large | L |
| Eraser | E |
| Clear Canvas | C C |
| Undo | Ctrl+Z |
| Redo | Ctrl+Y |
| Save | Ctrl+S |
| Pause Drawing | Space (hold) |
virtual-paint/
βββ main.py # Entry point
βββ requirements.txt
βββ src/
βββ config.py # Constants, asset paths, color palette
βββ camera.py # Camera open / read / enumerate
βββ tracker.py # HSV detection, tip and bounding rect
βββ painter.py # Canvas drawing, undo/redo, compositing
βββ ui/
βββ main_window.py # Main window, toolbars, menus, status bar
βββ paint_widget.py # Camera thread, frame pipeline, canvas display
βββ virtual_toolbar.py # In-frame overlay toolbar
βββ calibration_dialog.py # HSV calibration dialog
Python - PySide6 - OpenCV - NumPy
