A real-time virtual drawing application built with OpenCV and MediaPipe. This project detects hand gestures to allow users to draw, erase, and pause on a virtual canvas directly through the webcam.
- Live Drawing: Draw on the canvas by moving your index finger.
- Gesture Control: Use simple hand gestures to control the drawing process.
- Erase Canvas: Clear the entire canvas with a specific hand pose.
- Pause Drawing: Stop drawing without losing your progress.
- Smart Line Breaks: The application intelligently handles the start and end of drawing strokes.
The application recognizes the following hand gestures:
| Gesture | Action |
|---|---|
| Index Finger Up Only | ๐ข Draw |
| All Fingers Up | ๐ด Erase Canvas |
| Pinky Finger Up | ๐ Pause |
| Fist (All Bent) | โซ Wait/No Action |
To get this project up and running, follow these steps:
-
Clone the repository:
git clone https://github.com/MjavadH/virtual-air-canvas.git cd virtual-air-canvas -
Install the required dependencies:
pip install -r requirements.txt
Once the installation is complete, run the main script:
python src/main.pyHold your hand in front of the webcam and use the defined gestures to start drawing. Press the q key to exit the application.
This project uses MediaPipe Hands to track 21 hand landmarks. The drawing logic is based on geometric checks:
- Drawing Mode: Activated when only the Index finger is up (tip y < pip y).
- Smooth Lines: A
dequedata structure stores the coordinates to draw continuous lines and handle breaks efficiently.
This project is licensed under the MIT License. See the LICENSE file for details.
