A Python-based virtual mouse that uses hand gestures detected via webcam to control your computer's cursor.
- ☝ Cursor Movement: Move cursor with index finger
- 🤏 Left Click: Pinch gesture (thumb + index finger)
- ✌️ Right Click: Two fingers up (index + middle)
- 👊 Drag: Closed fist gesture
- 📜 Scroll: Palm open + move hand up/down
- 🎚️ Smooth Movement: Interpolated cursor with adjustable sensitivity
- 📊 Real-time FPS: Visual performance monitoring
- 🎨 Visual Feedback: Hand landmarks and gesture overlay
- Python 3.8 - 3.11 (recommended)
⚠️ Minimum: Python 3.8- ✅ Best compatibility: Python 3.9 or 3.10
⚠️ Python 3.12+ may have MediaPipe compatibility issues
- Webcam (built-in or USB)
- Operating System: Windows 10/11, Linux, or macOS
- Check your system (recommended):
python check_system.pyThis will verify your Python version, dependencies, and camera.
- Clone or navigate to the project directory:
cd n:\gesture-controller- Install dependencies:
pip install -r requirements.txtRun the application:
python main.py| Gesture | Action | Description |
|---|---|---|
| ☝ Index Finger Up | Move Cursor | Point with index finger to control cursor |
| 🤏 Pinch | Left Click | Bring thumb and index finger together |
| ✌️ Two Fingers | Right Click | Extend index and middle fingers |
| 👊 Fist | Drag | Close all fingers to drag items |
| ✋ Palm Open | Scroll | Open palm and move hand up/down |
| Key | Action |
|---|---|
Q |
Quit application |
S |
Toggle camera view on/off |
+ |
Increase cursor sensitivity |
- |
Decrease cursor sensitivity |
Move your mouse to the top-left corner of the screen to trigger PyAutoGUI's failsafe and stop the program.
You can adjust settings in main.py:
# Hand tracking confidence
detection_confidence=0.7
tracking_confidence=0.7
# Cursor smoothing (0-1, higher = smoother)
smoothing=0.7
# Cursor sensitivity (0.5-3.0)
sensitivity=1.5
# Gesture thresholds
pinch_threshold=40
fist_threshold=50gesture-controller/
├── main.py # Main application
├── hand_tracker.py # Hand detection using MediaPipe
├── gesture_detector.py # Gesture recognition logic
├── cursor_controller.py # Mouse control with PyAutoGUI
├── requirements.txt # Python dependencies
└── README.md # This file
- Check if your webcam is connected
- Try changing camera index in
main.py:cv2.VideoCapture(1)orcv2.VideoCapture(2)
- Reduce camera resolution in
main.py - Lower detection confidence
- Close other applications
- Press
+or-to adjust sensitivity in real-time - Modify
sensitivityparameter in code
- Ensure good lighting
- Keep hand within camera frame
- Adjust
pinch_thresholdandfist_thresholdvalues
- opencv-python: Camera capture and image processing
- mediapipe: Hand landmark detection
- pyautogui: Mouse control
- numpy: Mathematical operations
- FPS: 40-80 FPS (depending on CPU)
- Latency: ~20-50ms
- Accuracy: 21 hand landmarks tracked
Feel free to fork, modify, and improve this project!
MIT License - Feel free to use this project for personal or commercial purposes.
- MediaPipe by Google for hand tracking
- OpenCV for computer vision
- PyAutoGUI for mouse control
Enjoy your gesture-controlled mouse! 🎉