A production-ready virtual mouse application for hands-free computer control using camera-based hand gesture recognition.
cd virtual_mouse
pip install -r requirements.txt
python -m src.main --show-debug- 🤚 Real-time hand gesture recognition (MediaPipe)
- 🖱️ Full mouse control: move, click, drag, scroll
- ⚡ Performance optimized: 15-25% CPU usage
- 🎯 High accuracy with gesture smoothing
- 🪟 Cross-platform: Windows, Linux, macOS
- 🎛️ Fully configurable via environment variables
| Gesture | Action |
|---|---|
| ✋ Index Finger | Move Cursor |
| 👌 Pinch | Click |
| 🤏 Hold Pinch | Drag |
| ✌️ Middle Finger Up/Down | Scroll |
- Python 3.10+
- Webcam
- Windows 10/11, Linux, or macOS
cd virtual_mouse
# Option 1: Python command
pip install -r requirements.txt
python -m src.main --show-debug
# Option 2: Launcher script
./run_virtual_mouse.sh # Linux/macOS
run_virtual_mouse.bat # Windowspython -m src.main --auto-start --show-debug --log-level DEBUG# Camera
VM_CAMERA_RESOLUTION=960x540
VM_CAMERA_FPS=30
# Gestures
VM_GESTURE_SMOOTHING=0.25
VM_GESTURE_CLICK_THRESHOLD=0.035
# App
VM_APP_SHOW_DEBUG=false
VM_LOG_LEVEL=INFOFull configuration: See virtual_mouse/env.example
virtual_mouse/
├── src/
│ ├── main.py # Entry point
│ └── virtual_mouse/
│ ├── camera_module.py # Camera capture
│ ├── hand_tracking.py # MediaPipe wrapper
│ ├── gesture_controller.py # Gesture logic
│ └── virtual_mouse.py # Core engine
│
├── utils/
│ ├── config.py # Configuration
│ └── logger.py # Logging
│
├── tests/ # Unit tests
└── README.md # Full documentation
| Mode | CPU | Memory | FPS |
|---|---|---|---|
| Active | 15-25% | ~100MB | 30 |
| Idle | 3-8% | ~60MB | 10 |
Camera not opening?
- Close other apps using camera
- Try:
VM_CAMERA_INDEX=1
Hand not detected?
- Ensure good lighting
- Position hand 1-2 feet away
Jittery cursor?
- Increase smoothing:
VM_GESTURE_SMOOTHING=0.1
More help: See virtual_mouse/README.md
# Setup
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e .
pip install pytest black mypy pylint
# Test
pytest tests/ -v
# Format
black src/ utils/ tests/MIT License - see LICENSE
- MediaPipe - Hand tracking
- OpenCV - Computer vision
- PyAutoGUI - Mouse control
⭐ Star this repo • 🐛 Report issues • 🤝 Contribute