An AI-powered desktop application that allows you to draw on a digital canvas using hand gestures and control the interface with head movements. Built with Python, MediaPipe, OpenCV, and PyQt6.
- Hand Tracking: Uses MediaPipe Hands to detect hand landmarks in real-time.
- Gesture Drawing:
- Index Finger: Move the cursor.
- Pinch (Thumb + Index): Start drawing.
- Fist: Undo the last stroke.
- Head Gestures:
- Head Tilt (Left/Right): Cycle through brush colors.
- Head Nod (Up/Down): Adjust brush size.
- GUI Overlay: A transparent HUD built with PyQt6 showing the camera feed, stability bar, and current tool settings.
- Web Deployment Ready: Includes a fallback server for cloud deployments (Render/Heroku).
To run this project efficiently, you need the following Python packages:
opencv-python: For image processing and camera access.mediapipe: For AI-based hand and face tracking.numpy: For numerical operations and array handling.PyQt6: For the graphical user interface.
Follow these steps to set up the project on your local machine:
git clone https://github.com/Amit123103/HandDetectionDrawing.git
cd HandDetectionDrawingIt's best practice to use a virtual environment to manage dependencies.
Windows:
python -m venv .venv
.venv\Scripts\activatemacOS / Linux:
python3 -m venv .venv
source .venv/bin/activateInstall all required packages using pip:
pip install -r requirements.txtMake sure you have a webcam connected. Run the following command:
python main.pyThis will launch the application window.
If deploying to a cloud service like Render, the app will automatically start in Server Mode (API only) to prevent crashing on headless systems.
- Start Command:
python main.pyoruvicorn server:app --host 0.0.0.0 --port $PORT
| Gesture | Action |
|---|---|
| Index Finger | Move Cursor |
| Pinch (Index + Thumb) | Draw / Paint |
| Closed Fist | Undo Last Stroke |
| Head Tilt Left | Previous Color |
| Head Tilt Right | Next Color |
| Head Nod Up | Increase Brush Size |
| Head Nod Down | Decrease Brush Size |
ModuleNotFoundError: Ensure you have activated your virtual environment and installed requirements.- Camera not opening: Check if another application is using the webcam.
- Render Deployment: Remember that the drawing interface cannot be seen on Render. It is a backend deployment only. Run locally for the full experience.