A computer vision-based drawing application controlled by hand gestures. Built with Python, Tkinter, OpenCV, and MediaPipe.
- Hand Tracking: Real-time hand detection using MediaPipe.
- Gestures:
- Pinch (Index + Thumb): Draw or create shapes.
- Fist: Eraser (overrides all tools).
- Tools:
- Pen: Freehand drawing (smooth strokes).
- Shapes: Line, Rectangle, Circle (with live preview).
- Controls:
- Brush Size, Eraser Size, Shape Width.
- Color Picker (Presets + Custom).
- Undo / Redo / Clear.
- Save to PNG.
- UI:
- Live Camera Preview.
- Status Bar (FPS, Hand State).
- macOS (Apple Silicon recommended for performance) or any OS with Python support.
- Webcam.
- Python 3.11.
-
Create a Virtual Environment:
python3.11 -m venv .venv source .venv/bin/activate -
Install Dependencies:
pip install -r requirements.txt
-
Run the Application:
python main.py
-
Permissions (macOS):
- The first time you run it, macOS will ask for Camera permissions for your Terminal/IDE. Allow it.
-
How to Draw:
- Move Cursor: Move your hand. The cursor follows your index fingertip.
- Draw: Pinch your thumb and index finger together. Hold the pinch to draw. Release to stop.
- Shapes: Select a shape tool (Line/Rect/Circle). Pinch to set start point, drag to size, release to commit.
- Erase: Make a Fist. The cursor turns into an eraser. Rub over drawings to erase.
- Camera not opening: Ensure no other app is using the camera. Check terminal permissions in System Settings > Privacy & Security > Camera.
- Jittery Cursor: Adjust lighting. Ensure hand is clearly visible. The app includes smoothing, but extreme lighting conditions can affect tracking.