A comprehensive Python application that uses computer vision to detect hand gestures and control various desktop functions including media playback, volume control, scrolling, and navigation.
- π Open Palm (0.3s hold) β Play/Pause media (spacebar)
- β Fist (0.3s hold) β Mute/Unmute audio
- βοΈ Peace Sign Up (0.3s hold) β Next track/video
- βοΈ Peace Sign Down (0.3s hold) β Previous track/video
- βοΈ Index Finger Up (hold continuously) β Smooth scroll up with momentum
- βοΈ Index Finger Down (hold continuously) β Smooth scroll down with momentum
- π Thumbs Up (hold continuously) β Increase volume
- π Thumbs Down (hold continuously) β Decrease volume
βοΈ Swipe Left β Previous tab/slideβοΈ Swipe Right β Next tab/slide- π Both Palms Open (0.3s hold) β Toggle fullscreen
- Real-time hand detection using MediaPipe
- Gesture stability filtering to reduce false detections
- Momentum-based scrolling (speed increases with hold duration)
- Continuous volume control with smooth adjustment
- Multi-hand gesture support for advanced controls
- Swipe detection for horizontal navigation
- Visual feedback overlay showing gesture status and timing
- Comprehensive error handling and camera permission guidance
- Python 3.8 to 3.12 (MediaPipe compatibility)
- Webcam/camera access
- macOS, Windows, or Linux
chmod +x setup.sh
./setup.sh# Create virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run the application
python hand_gesture_controller.py- opencv-python: Computer vision and camera access
- mediapipe: Hand detection and landmark tracking
- pyautogui: Desktop automation and input simulation
- numpy: Numerical computations
- Start the application: Run
python hand_gesture_controller.py - Grant camera permissions when prompted (especially on macOS)
- Position yourself in front of the camera with good lighting
- Perform gestures as shown in the on-screen guide
- Press 'q' to quit the application
- Hold gestures steady for 0.3 seconds to trigger single-shot actions
- Keep holding scrolling and volume gestures for continuous control
- Use clear, distinct gestures - avoid partial or unclear hand positions
- Ensure good lighting for better hand detection
- Stay within camera frame with hands visible
| Gesture | Primary Shortcut | Fallback | Platform |
|---|---|---|---|
| Play/Pause | Space |
- | All |
| Mute | M |
- | All |
| Next Track | Shift + N |
- | All |
| Previous Track | Shift + P |
Left Arrow |
All |
| Volume Up/Down | Up Arrow Key/Down Arrow Key |
- | All |
| Next Tab | Cmd+Shift+] | Ctrl+Tab | macOS/Windows |
| Previous Tab | Cmd+Shift+[ | Ctrl+Shift+Tab | macOS/Windows |
| Fullscreen | F | - | All |
- macOS: Grant camera permissions in System Preferences > Security & Privacy > Privacy > Camera
- Windows: Check camera permissions in Settings > Privacy > Camera
- Linux: Ensure user is in
videogroup:sudo usermod -a -G video $USER
- MediaPipe requires Python 3.8-3.12
- Use
python3 --versionto check your version - Consider using
pyenvor virtual environments for version management
- Ensure good lighting for better hand detection
- Close other applications using the camera
- Lower camera resolution if needed (modify
setup_camera()method)
- Make clear, distinct gestures
- Hold gestures steady for the required duration
- Ensure hands are fully visible in camera frame
- Check the finger state display for debugging
Edit these parameters in hand_gesture_controller.py:
self.gesture_threshold = 0.3 # Time to hold gesture (seconds)
self.stability_threshold = 0.6 # Gesture stability filteringself.scroll_interval = 0.08 # Time between scroll events
self.base_scroll_amount = 2 # Base scroll speed
self.max_scroll_amount = 5 # Maximum scroll speed with momentumself.volume_interval = 0.2 # Time between volume changesThe application uses a class-based architecture with the following key components:
HandGestureController: Main controller class- Gesture Detection: MediaPipe-based hand landmark analysis
- Stability Filtering: Reduces noise and false detections
- Action Handlers: Separate methods for each gesture action
- Visual Feedback: Real-time overlay showing gesture status
- Error Handling: Comprehensive error management and recovery
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
- MediaPipe by Google for hand detection
- OpenCV for computer vision capabilities
- PyAutoGUI for desktop automation