Transform your webcam into a sophisticated AI-powered input device
Desktop-grade cursor control with intuitive hand gestures
Features • Gestures • Installation • Usage • Configuration • Architecture
HandGestureDetector is a premium, AI-powered virtual mouse system that replaces your physical mouse with natural hand gestures. Built with MediaPipe's advanced hand tracking and high-performance interpolation algorithms, it delivers smooth, responsive cursor control that rivals traditional input devices.
Perfect for:
- 🎓 Presentations - Control slides hands-free
- ♿ Accessibility - Alternative input method for users with mobility challenges
- 🎮 Interactive Displays - Touch-free interaction for public installations
- 🚀 Innovation - Explore the future of human-computer interaction
|
Uses the palm's center of mass instead of fingertips for rock-solid, jitter-free cursor movement. |
Independently detects left and right hands, enabling complex multi-hand gestures and interactions. |
|
High-frequency interpolation layer ensures buttery-smooth cursor movement comparable to premium gaming mice. |
Velocity-based scroll with acceleration curves and dead-zones for natural, precise document navigation. |
|
Real-time telemetry window + dedicated hand skeleton visualization for complete system transparency. |
Accidental input prevention with 3-second hold gesture to enable/disable the entire system. |
| Gesture | Visual | Hand Configuration | Action | Notes |
|---|---|---|---|---|
| Cursor Move | ☝️ | Index finger extended Other fingers curled |
Move cursor Palm-center tracking |
Primary control gesture 120Hz interpolation |
| Left Click | 🤏 | Thumb + Index pinch Distance < 40px |
Single click 300ms cooldown |
Quick pinch = click Hold for drag |
| Drag & Drop | 🤏⏱️ | Pinch held > 500ms | Click + Hold Drag mode active |
Release pinch to drop Visual indicator shown |
| Vertical Scroll | ✌️ | Index + Middle up Other fingers down |
Scroll up/down Velocity-based |
Fast hand = fast scroll Acceleration enabled |
| Toggle System | ✊⏱️ | Closed fist Hold for 3 seconds |
Enable/Disable System control |
Safety feature Visual feedback shown |
| Gesture | Visual | Hand Configuration | Action | Notes |
|---|---|---|---|---|
| Right Click | 🤏 | Thumb + Index pinch (Left hand) |
Context menu Right-click action |
Independent of right hand 300ms cooldown |
| Gesture | Visual | Hand Configuration | Action | Notes |
|---|---|---|---|---|
| Minimize Window | 🤏🤏 | Both hands pinch Simultaneously |
Hide active app Minimize to taskbar |
500ms timing tolerance Works across all apps |
| Open Terminal | ✊✊⚡⚡ | Both hands closed fist Pinch twice rapidly |
Launch terminal Windows Terminal/cmd |
Double-pinch gesture Quick succession |
6 Single-Hand Gestures + 2 Dual-Hand Gestures = 8 Total Commands
HandGestureDetector follows a 3-layer self-annealing architecture for maximum stability, maintainability, and extensibility:
┌─────────────────────────────────────────────────────────────┐
│ 1. DIRECTIVES LAYER │
│ Standard Operating Procedures (Markdown) │
│ Defines WHAT to do │
└────────────────────────┬────────────────────────────────────┘
│
┌────────────────────────▼────────────────────────────────────┐
│ 2. ORCHESTRATION LAYER │
│ Core Logic (main.py + /modules) │
│ Manages data flow between sensors & executors │
└────────────────────────┬────────────────────────────────────┘
│
┌────────────────────────▼────────────────────────────────────┐
│ 3. EXECUTION LAYER │
│ Deterministic Scripts (/execution) │
│ Environment-specific tasks & OS-level calls │
└─────────────────────────────────────────────────────────────┘
| Layer | Location | Purpose | Example |
|---|---|---|---|
| Directives | /directives/*.md |
Define system behavior and requirements | Gesture definitions, timing thresholds |
| Orchestration | /modules/*.py, main.py |
Coordinate between components | Hand detection → Gesture recognition → Action |
| Execution | /execution/*.py |
Perform platform-specific operations | Window management, terminal launch |
This architecture ensures:
- ✅ Separation of Concerns - Each layer has a single responsibility
- ✅ Easy Maintenance - Change directives without touching code
- ✅ Cross-Platform - Swap execution scripts per OS
- ✅ Testability - Mock layers independently
![]() Python 3.10+ Core Runtime |
![]() MediaPipe Hand Tracking AI |
![]() OpenCV Computer Vision |
PySide6 (Qt) GUI Framework |
Additional Libraries:
- pynput - Cross-platform mouse control
- pygetwindow - Window management (Windows)
- screeninfo - Multi-monitor support
- numpy - Numerical operations
- Python 3.8+ (Download here)
- Webcam (built-in or USB)
- Windows/Linux/macOS (cross-platform support)
# Clone the repository
git clone https://github.com/yourusername/HandGestureDetector.git
cd HandGestureDetector
# Run the launcher (automatically sets up environment)
run.bat# Clone the repository
git clone https://github.com/yourusername/HandGestureDetector.git
cd HandGestureDetector
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the application
python main.pyFor window management features on Linux:
sudo apt-get update
sudo apt-get install wmctrl- Launch the application using
run.bat(Windows) orpython main.py(all platforms) - Allow webcam access when prompted
- Two windows will appear:
- Status Dashboard - System telemetry and controls
- Hand Visualization - Live hand skeleton overlay
- Show your RIGHT hand to the camera
- System detects hand and displays green skeleton
- Extend INDEX finger only
- Cursor begins tracking palm movement
- Pinch THUMB + INDEX together
- Performs left click
- Hold pinch for 500ms
- Enters drag mode (move hand while pinching)
- Show BOTH hands and pinch simultaneously
- Minimizes active window
To disable virtual mouse control (prevent accidental inputs):
- Make a closed fist with right hand
- Hold for 3 seconds
- System displays "DISABLED" status
To re-enable:
- Repeat the same gesture
- ✅ Lighting - Ensure good lighting on your hands
- ✅ Background - Plain backgrounds improve detection
- ✅ Distance - Keep hands 1-2 feet from camera
- ✅ Angle - Face palms toward camera for best tracking
- ✅ Calibration - First-time users: adjust sensitivity in settings
All settings are located in config/settings.py. Customize the system to your preferences:
CONFIG = {
# Detection
'MIN_DETECTION_CONFIDENCE': 0.7, # Hand detection threshold (0-1)
'MIN_TRACKING_CONFIDENCE': 0.5, # Tracking stability threshold
'MAX_NUM_HANDS': 2, # Enable dual-hand detection
# Cursor Control
'CURSOR_SMOOTHING_ALPHA': 0.3, # Lower = smoother (0.1-0.5)
'CURSOR_DEAD_ZONE_PX': 5, # Minimum movement threshold
'INTERPOLATION_RATE_HZ': 120, # Cursor refresh rate
# Gestures
'CLICK_THRESHOLD_PX': 40, # Pinch distance for click
'DRAG_HOLD_TIME_MS': 500, # Hold duration to start drag
'CLICK_COOLDOWN_MS': 300, # Prevent double-clicks
# Scroll
'SCROLL_SENSITIVITY': 1.5, # Scroll speed multiplier
'SCROLL_ACCELERATION_ENABLED': True,
'SCROLL_SMOOTHING_FRAMES': 10,
# Toggle
'TOGGLE_HOLD_DURATION_MS': 3000, # Fist hold time to toggle
# Display
'CAMERA_WIDTH': 640,
'CAMERA_HEIGHT': 480,
'MIRROR_CAMERA': True, # Mirror for natural movement
}For slower computers:
'INTERPOLATION_RATE_HZ': 60, # Reduce to 60Hz
'CAMERA_WIDTH': 320, # Lower resolution
'CAMERA_HEIGHT': 240,For ultra-smooth experience:
'INTERPOLATION_RATE_HZ': 240, # Increase to 240Hz
'CURSOR_SMOOTHING_ALPHA': 0.2, # More aggressive smoothingHandGestureDetector/
│
├── 📁 config/ # Configuration files
│ └── settings.py # System settings and constants
│
├── 📁 directives/ # Standard Operating Procedures
│ ├── gesture_definitions.md # Gesture specifications
│ └── system_behavior.md # System logic definitions
│
├── 📁 execution/ # Platform-specific executors
│ ├── window_manager.py # Window management (minimize, etc.)
│ └── terminal_launcher.py # Terminal/cmd launcher
│
├── 📁 modules/ # Core application logic
│ ├── init.py
│ ├── hand_detector.py # MediaPipe hand detection wrapper
│ ├── gesture_recognizer.py # Gesture identification logic
│ ├── cursor_smoother.py # Cursor smoothing algorithms
│ ├── mouse_controller.py # Mouse action executor
│ ├── state_manager.py # System state machine
│ └── gui_dashboard.py # PySide6 GUI components
│
├── 📁 utils/ # Helper utilities
│ ├── init.py
│ ├── helpers.py # Utility functions
│ ├── error_handler.py # Error management
│ ├── calibration.py # Calibration wizard
│ └── visualization.py # OpenCV drawing functions
│
├── 📄 main.py # Application entry point
├── 📄 run.bat # Windows launcher script
├── 📄 requirements.txt # Python dependencies
├── 📄 README.md # This file
├── 📄 LICENSE # MIT License
└── 📄 .gitignore # Git ignore rules
Copyright (c) 2024 HandGestureDetector Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: [Full license text...]
- MediaPipe Team - For the incredible hand tracking ML model
- OpenCV Community - For robust computer vision tools
- Qt/PySide6 - For the professional GUI framework
- Contributors - Everyone who has helped improve this project
Project Maintainer: Your Name
- GitHub: @yourusername
- Email: your.email@example.com
- Twitter: @yourhandle
Project Link: https://github.com/yourusername/HandGestureDetector
If this project helped you, please consider giving it a ⭐️!
Made with ❤️ and ☕ for a more intuitive desktop experience
Built with Python • Powered by MediaPipe • Designed for Everyone




