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.
- π Features
- π» System Requirements
- βοΈ Installation
- π¬ Usage
- ποΈ Application Architecture
- π§© Core Components
- π§ Configuration
- π Troubleshooting
- π License
- π€³ 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
- π Python 3.7+
- πΈ Webcam (recommended min 640x480 resolution)
- π» OS: Windows, macOS, or Linux
- π Internet (for installing dependencies)
git clone https://github.com/suraj5424/virtual-gesture-mouse.git
cd virtual-gesture-mousepython -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate.bat # Windowspip install -r requirements.txtstreamlit run app.py- π Open the displayed URL (usually 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 | Action |
|---|---|
| βοΈ Index finger up | Move mouse cursor |
| π€ Pinch thumb + index finger | Left mouse click |
The app consists of two main parts:
- Streamlit UI and sidebar controls
- Webcam capture and video display
- Main gesture loop for detecting hand movement and controlling mouse
- Uses
gesturecontrol.pyfor hand landmark processing
-
HandDetectorclass leveraging MediaPipe Hands -
Hand detection, landmark extraction, and finger state analysis
-
Utility functions:
find_hands()β detect & draw handsfind_position()β get landmark positions and bounding boxfind_distance()β compute distance between landmarksfinger_up()β check which fingers are raised
- MediaPipe Hands detects 21 landmarks per hand
- Tracks single hand for cursor control
- Checks which fingers are up (1 = up, 0 = down)
- Index finger up β cursor moves
- Pinched thumb + index β mouse click
- Maps webcam frame coords β screen coords
- Control frame margin restricts active area
- Movement smoothing avoids jitter
| 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 |
| 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 |
This project is licensed under the MIT License β feel free to use and modify freely! π
π¨βπ» Created by Suraj Varma π» GitHub: suraj5424
β¨ Thanks for checking out Virtual Gesture Mouse β control your PC with a wave of your hand! βπ±οΈπ
