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! π―π±οΈβ¨
- Host: GitHub
- URL: https://github.com/suraj5424/virtual-gesture-mouse
- Owner: suraj5424
- License: mit
- Created: 2025-06-08T02:11:16.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-08T03:36:23.000Z (about 1 year ago)
- Last Synced: 2025-06-23T16:05:12.592Z (12 months ago)
- Topics: autopy, autopygui, computer-vision, opencv, python, streamlit, virtual-mouse-using-hand-gesture
- Language: Python
- Homepage:
- Size: 6.06 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.
---

---
## π 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! βπ±οΈπ