A real-time hand gesture recognition system that uses computer vision to control your computer's volume through hand gestures. Built with Python, OpenCV, and MediaPipe.
- Real-time Hand Detection: Uses MediaPipe for accurate hand landmark detection
- Volume Control: Control system volume with simple hand gestures
- Multiple Gestures: Support for index finger up and fist gestures
- Live Video Feed: Real-time camera feed with hand landmark visualization
- Cross-platform: Works on Windows, macOS, and Linux
- Easy to Use: Simple setup and intuitive gesture controls
| Gesture | Action | Description |
|---|---|---|
| ๐ Index Finger Up | Increase Volume | Point your index finger upward |
| โ Fist | Decrease Volume | Make a fist with your hand |
- Python 3.9 or higher
- Webcam
- Windows OS (for volume control functionality)
git clone <repository-url>
cd hand_gesturepip install -r requirements.txtFor volume control on Windows, install:
pip install pycawpython main.py- Start the Program: Run
python main.py - Show Your Hand: Position your hand in front of the camera
- Make Gestures:
- Index finger up โ Increase volume by 1%
- Fist โ Decrease volume by 1%
- Exit: Press
ESCkey to quit
- Ensure good lighting conditions
- Keep your hand clearly visible to the camera
- Maintain a reasonable distance from the camera (30-200cm)
- Use clear, deliberate gestures
hand_gesture/
โโโ main.py # Main application entry point
โโโ requirements.txt # Python dependencies
โโโ README.md # Project documentation
โโโ src/
โ โโโ __init__.py # Package initialization
โ โโโ camera.py # Camera interface and frame capture
โ โโโ hand_detector.py # Hand detection using MediaPipe
โ โโโ gesture_classifier.py # Gesture recognition logic
โ โโโ volume_control.py # System volume control interface
โ โโโ config.py # Configuration settings
โ โโโ utils.py # Utility functions
Edit src/config.py to customize settings:
# Camera settings
CAMERA_ID = 0 # Camera device ID
FRAME_WIDTH = 640 # Frame width
FRAME_HEIGHT = 480 # Frame height
# Hand detection settings
MAX_NUM_HANDS = 1 # Maximum hands to detect
DETECTION_CONFIDENCE = 0.7 # Detection confidence threshold
TRACKING_CONFIDENCE = 0.7 # Tracking confidence threshold
# Distance settings
MIN_DISTANCE = 30 # Minimum hand distance
MAX_DISTANCE = 200 # Maximum hand distance- Handles webcam initialization and frame capture
- Supports configurable resolution and camera selection
- Uses MediaPipe for real-time hand landmark detection
- Tracks 21 hand landmarks (fingertips, joints, etc.)
- Provides hand skeleton visualization
- Analyzes hand landmarks to classify gestures
- Currently supports:
- Index Finger Up: Landmark 8 (fingertip) above landmark 6 (joint)
- Fist: All fingers closed
- Interfaces with Windows audio system using
pycaw - Provides volume get/set functionality
- Handles volume range mapping (0-100%)
MediaPipe detects 21 hand landmarks:
- Landmarks 0-4: Thumb
- Landmarks 5-8: Index finger
- Landmarks 9-12: Middle finger
- Landmarks 13-16: Ring finger
- Landmarks 17-20: Pinky
Error: Could not open camera!
Solution: Check if your webcam is connected and not in use by another application.
ModuleNotFoundError: No module named 'mediapipe'
Solution: Install MediaPipe for your Python version:
pip install mediapipeSolution: Ensure you're running on Windows and have pycaw installed:
pip install pycawSolutions:
- Improve lighting conditions
- Keep hand clearly visible
- Adjust distance from camera
- Check detection confidence settings
- Use a good quality webcam for better detection
- Ensure adequate lighting
- Close unnecessary applications to free up system resources
- Adjust confidence thresholds in
config.pyif needed
- Support for more gestures (thumbs up, peace sign, etc.)
- Gesture recording and custom gesture training
- Support for multiple hands
- Cross-platform volume control
- GUI interface
- Gesture history and statistics
- Machine learning-based gesture recognition
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe - Hand tracking and detection
- OpenCV - Computer vision library
- pycaw - Windows audio control
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Search existing issues in the repository
- Create a new issue with detailed information
Made with โค๏ธ for computer vision enthusiasts