A real-time hand gesture-controlled drawing application using OpenCV and MediaPipe. Draw, erase, and control the entire interface using just your webcam and hand gestures!
- ๐๏ธ Advanced Hand Gesture Recognition - 5 distinct gesture modes
- ๐จ 6 Color Options - Pink, Blue, Green, Orange, Purple, White
- ๐ฑ๏ธ Cursor Mode - Control UI with hand gestures (1-second dwell click)
- ๐งน Eraser Tool - Toggle between drawing and erasing
- โฉ๏ธ Undo Functionality - Undo up to 20 strokes
- ๐ Adjustable Brush Size - Gesture-based thickness control
- โจ๏ธ Keyboard Shortcuts - Fast control with hotkeys
- ๐พ Modern Sidebar UI - Clean, glassmorphic interface
- ๐ฏ High Accuracy - Improved finger detection algorithm
- Python 3.10 or 3.11 (MediaPipe doesn't support 3.13 yet)
- Webcam (built-in or external)
- Good lighting for optimal hand tracking
conda create -n drawpad python=3.10 -y
conda activate drawpad
cd drawpad
pip install -r requirements.txtpython -m venv venv
venv\Scripts\activate
source venv/bin/activate
pip install -r requirements.txtpython main.py| Gesture | Fingers | Action |
|---|---|---|
| โ๏ธ Cursor Mode | Index + Middle | Control UI, hover to click buttons |
| ๐ Draw | Index only | Draw on canvas |
| ๐ค Standby | Index + Pinky | Pause drawing |
| โ Clear | Closed fist | Clear entire canvas |
| ๐ค Adjust Size | Thumb + Index (+ Pinky to confirm) | Change brush thickness |
| Key | Action |
|---|---|
C |
Toggle Cursor Mode |
E |
Toggle Eraser |
U |
Undo last stroke |
X |
Clear canvas |
1 |
Pink color |
2 |
Blue color |
3 |
Green color |
4 |
Orange color |
5 |
Purple color |
6 |
White color |
Q |
Quit application |
How to Click Buttons with Hand Gestures:
- โ๏ธ Raise Index + Middle fingers (keep others down)
- A green cursor appears on screen
- Move your hand to position the cursor over a button
- Hold still for 1 second
- Watch the green ring fill up around the cursor
- Button auto-clicks when ring completes!
Tip: Use keyboard shortcuts for faster control!
drawpad/
โโโ main.py # Main application
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ screenshots/ # Demo images (optional)
opencv-python>=4.11.0
mediapipe>=0.10.21
numpy>=1.26.4
- โ Use good lighting (natural or bright artificial light)
- โ Keep your hand flat and visible to the camera
- โ Make clear finger positions (strict detection)
- โ Position yourself 1-2 feet from the camera
- โ Use a plain background for better tracking
- โ Avoid fast movements for smoother drawing
# Make sure you're using Python 3.10 or 3.11
python --version
# If using 3.13, create new environment with 3.10
conda create -n drawpad python=3.10 -y# Try changing camera index in main.py (line 168)
cap = cv2.VideoCapture(0) # Try 0, 1, or 2- Improve lighting
- Move closer to camera
- Ensure hand is fully visible
- Check camera permissions
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
Created with โค๏ธ using OpenCV and MediaPipe