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

https://github.com/suraj5424/virtual-gesture-mouse

πŸ–οΈ Control your computer’s mouse using real-time hand gestures with this virtual gesture mouse app! πŸš€ Easy setup, smooth navigation, and click control β€” no hardware needed! πŸŽ―πŸ–±οΈβœ¨
https://github.com/suraj5424/virtual-gesture-mouse

autopy autopygui computer-vision opencv python streamlit virtual-mouse-using-hand-gesture

Last synced: about 1 month ago
JSON representation

πŸ–οΈ Control your computer’s mouse using real-time hand gestures with this virtual gesture mouse app! πŸš€ Easy setup, smooth navigation, and click control β€” no hardware needed! πŸŽ―πŸ–±οΈβœ¨

Awesome Lists containing this project

README

          

# πŸ–οΈβœ¨ Virtual Gesture Mouse β€” Documentation πŸ–±οΈπŸ€–

---

## πŸš€ Overview

**Virtual Gesture Mouse** lets you control your computer πŸ–₯️ mouse cursor and clicks πŸ–±οΈ using simple hand gestures captured by your webcam πŸ“Έ.
Powered by **MediaPipe** 🀳 for hand tracking, **OpenCV** πŸ–ΌοΈ for video processing, **Autopy** 🐍 for mouse control, and **Streamlit** 🎨 for an interactive UI.

---

Demo of Virtual Gesture Mouse

---
## πŸ“š Table of Contents

- [🌟 Features](#-features)
- [πŸ’» System Requirements](#-system-requirements)
- [βš™οΈ Installation](#%EF%B8%8F-installation)
- [🎬 Usage](#-usage)
- [πŸ—οΈ Application Architecture](#%EF%B8%8F-application-architecture)
- [🧩 Core Components](#-core-components-explained)
- [πŸ”§ Configuration](#-configuration-parameters)
- [🐞 Troubleshooting](#-troubleshooting)
- [πŸ“„ License](#-license)

---

## 🌟 Features

- 🀳 Real-time hand tracking with MediaPipe
- πŸ–±οΈ Cursor movement controlled by your index finger
- πŸ‘Œ Mouse clicks by pinching thumb and index finger
- βš™οΈ Adjustable webcam resolution, frame margin, smoothing & click sensitivity
- πŸ‘οΈ Visual feedback: bounding boxes, landmarks, FPS display
- πŸ–₯️ Friendly, responsive UI built with Streamlit

---

## πŸ’» System Requirements

- 🐍 Python 3.7+
- πŸ“Έ Webcam (recommended min 640x480 resolution)
- πŸ’» OS: Windows, macOS, or Linux
- 🌐 Internet (for installing dependencies)

---

## βš™οΈ Installation

### Step 1: Clone the repo

```bash
git clone https://github.com/suraj5424/virtual-gesture-mouse.git
cd virtual-gesture-mouse
````

### Step 2: Setup virtual environment (recommended)

```bash
python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate.bat # Windows
```

### Step 3: Install dependencies

```bash
pip install -r requirements.txt
```

---

## 🎬 Usage

### Run the app

```bash
streamlit run app.py
```

* 🌐 Open the displayed URL (usually [http://localhost:8501](http://localhost:8501))
* πŸŽ›οΈ Adjust settings in the sidebar (webcam size, smoothing, click threshold, etc.)
* ▢️ Click **Start Gesture Mouse** to begin controlling the mouse
* ⏹️ Click **Stop Gesture Mouse** to pause control

### Gesture Controls

| Gesture | Action |
| ----------------------------- | ----------------- |
| ☝️ Index finger up | Move mouse cursor |
| 🀏 Pinch thumb + index finger | Left mouse click |

---

## πŸ—οΈ Application Architecture

The app consists of two main parts:

### 1. `app.py` 🎨

* Streamlit UI and sidebar controls
* Webcam capture and video display
* Main gesture loop for detecting hand movement and controlling mouse
* Uses `gesturecontrol.py` for hand landmark processing

### 2. `gesturecontrol.py` 🧩

* `HandDetector` class leveraging MediaPipe Hands
* Hand detection, landmark extraction, and finger state analysis
* Utility functions:

* `find_hands()` β€” detect & draw hands
* `find_position()` β€” get landmark positions and bounding box
* `find_distance()` β€” compute distance between landmarks
* `finger_up()` β€” check which fingers are raised

---

## 🧩 Core Components Explained

### 🀳 Hand Detection

* MediaPipe Hands detects 21 landmarks per hand
* Tracks single hand for cursor control

### βœ‹ Gesture Recognition Logic

* Checks which fingers are up (1 = up, 0 = down)
* Index finger up β†’ cursor moves
* Pinched thumb + index β†’ mouse click

### πŸ–±οΈ Cursor Movement Mapping

* Maps webcam frame coords β†’ screen coords
* Control frame margin restricts active area
* Movement smoothing avoids jitter

---

## πŸ”§ Configuration Parameters

| Parameter | Description | Default | Range |
| ---------------------------------- | ---------------------------------------------- | ------- | ---------- |
| πŸ“· Webcam Width (`wCam`) | Video capture width | 640 | 400 - 1280 |
| πŸ“Έ Webcam Height (`hCam`) | Video capture height | 480 | 300 - 720 |
| πŸ–ΌοΈ Control Frame Margin (`framR`) | Active area margin inside webcam frame | 100 | 20 - 200 |
| πŸŒͺ️ Mouse Smoothing | Smooth factor to reduce jitter | 7 | 1 - 15 |
| πŸ–±οΈ Click Threshold | Max distance between thumb and index for click | 40 | 10 - 100 |

---

## 🐞 Troubleshooting

| Issue | Solution |
| ------------------------------ | ------------------------------------- |
| 🚫 Webcam not detected | Check webcam connection & permissions |
| βœ‹ Gesture control unresponsive | Restart app; check hand visibility |
| πŸŒ€ Cursor moves erratically | Increase smoothing value |
| πŸ‘† Clicks not registering | Adjust click distance threshold |

---

## πŸ“„ License

This project is licensed under the [MIT License](LICENSE) β€” feel free to use and modify freely! πŸ“

---

## πŸ“¬ Contact

πŸ‘¨β€πŸ’» Created by [Suraj Varma](https://www.linkedin.com/in/suraj5424/)
πŸ’» GitHub: [suraj5424](https://github.com/suraj5424)

---

✨ Thanks for checking out **Virtual Gesture Mouse** β€” control your PC with a wave of your hand! βœ‹πŸ–±οΈπŸš€