An open API service indexing awesome lists of open source software.

https://github.com/venkat-0706/air-drawing

A real-time hand gesture drawing app using Python, OpenCV, and MediaPipe to draw, erase, and switch colors on a canvas using finger gestures via webcam.
https://github.com/venkat-0706/air-drawing

computer-vision hand-gesture-recognition mediapipe mediapipe-hands numpy opencv-python python realtime-object-tracker

Last synced: 3 months ago
JSON representation

A real-time hand gesture drawing app using Python, OpenCV, and MediaPipe to draw, erase, and switch colors on a canvas using finger gestures via webcam.

Awesome Lists containing this project

README

          

# ๐ŸŽจ Hand Gesture Drawing App

> Control your canvas using just your hand.
> **Draw, erase, and switch colors** in real-time using intuitive hand gestures detected via webcam.

---

![Python](https://img.shields.io/badge/Python-3.7+-blue?logo=python\&logoColor=white)
![OpenCV](https://img.shields.io/badge/OpenCV-4.x-green?logo=opencv)
![MediaPipe](https://img.shields.io/badge/MediaPipe-Hands-red?logo=google)
![UI](https://img.shields.io/badge/UI-Realtime--Overlay-orange)

---

## ๐Ÿง  Key Features

| Feature | Description |
|------------------------------|-----------------------------------------------------------------------------|
| ๐ŸŽจ **Air Drawing** | Draw lines on a canvas using your index finger in real-time |
| ๐Ÿงผ **Erasing** | Make a fist gesture to erase parts of the drawing |
| ๐ŸŒˆ **Color Palette Switching**| Hover over virtual palette to switch between red, green, and blue |
| ๐Ÿ–ฅ๏ธ **Live Feedback UI** | See gestures drawn live on the video stream with MediaPipe hand overlays |
| โšก **Smooth Drawing Engine** | High-performance canvas rendering with OpenCV and NumPy |

---

## โœ‹ Gesture Recognition Logic

| Gesture | Action |
|----------------------------------|-------------------|
| โœ๏ธ Index finger up only | Draw |
| โœŠ All fingers down (fist) | Erase |
| โœŒ๏ธ Two fingers up | Color selection |
| ๐Ÿ–๏ธ Open palm | Idle / reset |

MediaPipe detects **21 landmarks per hand**. Gesture logic is implemented by comparing fingertip and lower-joint positions to determine finger states.

---

## ๐Ÿ”ง Tech Stack

### ๐Ÿงช Core Technologies

| Tech | Role |
|----------------|--------------------------------------------------------|
| **Python 3.7+**| Programming Language |
| **OpenCV** | Webcam streaming, canvas rendering, drawing functions |
| **MediaPipe** | Real-time hand tracking and 3D landmark detection |
| **NumPy** | Array operations for efficient image processing |

### ๐ŸŽจ Drawing System

| Component | Tool/Function |
|------------------|----------------------------|
| Line Drawing | `cv2.line()` |
| Circle Erasing | `cv2.circle()` |
| Canvas Overlay | NumPy + OpenCV masking |
| Color Palette UI | On-screen rectangles |

---

## ๐Ÿ“ฅ Installation

```bash
# Clone this repository
git clone https://github.com/yourusername/hand-gesture-drawing.git
cd hand-gesture-drawing

# Install required libraries
pip install opencv-python mediapipe numpy

# Run the application
python app.py
````

---

## ๐Ÿ–ผ๏ธ Screenshots

| Drawing Mode | Eraser Mode | Color Palette |
| ------------------------- | -------------------------- | -------------------------- |
| ![](screenshots/draw.png) | ![](screenshots/erase.png) | ![](screenshots/color.png) |

---

## ๐Ÿงฉ How It Works

1. ๐Ÿ–ฅ๏ธ OpenCV captures real-time video from the webcam
2. โœ‹ MediaPipe detects 21 hand landmarks
3. ๐Ÿง  Gesture logic determines if fingers are up/down
4. ๐ŸŽจ Drawing or erasing actions are applied on a NumPy-based canvas
5. ๐Ÿ” The canvas is overlaid on the webcam stream for a real-time visual experience

---

## โš™๏ธ Customization Options

* ๐ŸŽฏ **Add New Colors:** Modify `colors[]` and `color_names[]` lists
* โœ๏ธ **Change Brush/Eraser Size:** Update `brush_thickness` and `eraser_thickness`
* ๐Ÿ“ค **Save Canvas:** Use `cv2.imwrite('drawing.png', canvas)`
* ๐Ÿ‘‡ **Add More Gestures:** Expand the `fingers_up()` logic for new controls

---

## ๐Ÿ“… Future Improvements

* [ ] Gesture to clear entire canvas
* [ ] Option to save drawings via GUI button or gesture
* [ ] Streamlit/Flask web interface
* [ ] Add more brushes (dotted, calligraphy)

---

---

### โœ… Why This Works Better

* Pure markdown = more reliable across GitHub, GitLab, Bitbucket, etc.
* Respects dark/light modes.
* Easier to edit and maintain.

---

## ๐Ÿ™‹ Author

Made with โค๏ธ by [Chandu](https://github.com/venkat-0706)

๐Ÿ”— Connect on [Linkedin](https://www.linkedin.com/in/chandu-0706)

---

## ๐Ÿ“„ License

This project is licensed under the **MIT License**. Feel free to use and modify it as you wish!

---


If you like this project, consider giving it a โญ and sharing it!


```

---

### โœ… Next Steps for You:

* Replace placeholders like `yourusername`, image paths, and LinkedIn links.
* Add a demo GIF in `screenshots/demo.gif`
* Create high-quality screenshots of each mode (drawing, erasing, color switching).