A real-time AI-powered virtual painting app that lets you draw on your screen using just your hand and a webcam—no mouse or stylus required! Built with OpenCV and MediaPipe for fast, accurate hand tracking and gesture recognition.
- Real-time Hand Tracking
MediaPipe’s hand landmark model enables precise fingertip detection and tracking. - Gesture-Based Controls
- Index Finger Up: Draw on the canvas.
- Index + Middle Fingers Up: Open color selection panel; hover to pick a color.
- Thumb + Pinky: Switch to eraser mode.
- Customizable Tools
Adjust brush thickness and eraser size for detailed work. - Multi-Color Palette
Instantly switch colors by hovering over the palette region. - Cross-Platform
Works with any standard webcam on Windows, macOS, or Linux.
- Python 3.7+
- OpenCV – Video capture, image processing, UI overlays
- MediaPipe – Hand landmark detection, gesture recognition
- NumPy – Efficient image matrix operations
-
Clone the repository
git clone https://github.com/IbrahimBagwan1/hand-tracking-virtual-painter.git cd hand-tracking-virtual-painter -
(Optional) Create & activate a virtual environment
python -m venv venv # Windows venv\Scripts\activate # macOS / Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
- Connect your webcam.
- Run the painter script:
python app_virtual_painter.py
- Start drawing!
Controls:
- Drawing Mode: Raise index finger
- Color Selection: Raise index + middle fingers, hover over a color in the top bar
- Eraser Mode: Make thumb + pinky gesture
- Quit: Press
xat any time
- Hand Landmark Detection:
MediaPipe locates 21 hand landmarks in each video frame. - Gesture Recognition:
- Drawing: Only index fingertip above its PIP joint
- Selection: Both index and middle fingertips up
- Eraser: Thumb and pinky fingertips up together
- Canvas Overlay:
Drawing strokes are accumulated on a transparent canvas and overlaid on the live video feed using OpenCV.
Keywords: Hand Tracking, Virtual Painter, Gesture Recognition, OpenCV, MediaPipe, Python Drawing App, Real-time AI Drawing
Description: Create stunning drawings with just your hand—no stylus or tablet needed. Leverage AI-driven hand tracking for an intuitive, marker-free digital painting experience.
Distributed under the MIT License. See LICENSE for details.
Contributions are welcome! To report bugs or propose enhancements:
- Fork this repository
- Create a new branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -m "Add my feature") - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
Please ensure all new code is well-documented and tested.
Created by Ibrahim Bagwan
Questions or feedback? Reach out via GitHub Issues
Enjoy painting with your hands! 🎨✋