This project enables users to control the system volume using hand gestures. It utilizes OpenCV for real-time hand tracking, Mediapipe for hand landmark detection, and Pycaw for audio control.
- Adjust system volume using finger distance
- Uses a green rectangle (detection box) to limit gesture recognition area
- Displays real-time volume percentage on the screen
Ensure you have the following installed:
- Python 3.x
- OpenCV (
cv2) - Mediapipe
- Pycaw (for audio control)
Install dependencies using:
pip install opencv-python mediapipe pycaw numpy comtypes- Clone this repository:
git clone https://github.com/your-username/hand-gesture-volume-control.git cd hand-gesture-volume-control - Run the script:
python main.py
- The script will open a webcam window.
- Place your hand inside the green rectangle (box) for detection.
- Move your index finger and thumb closer or farther apart to adjust volume:
- Increase volume: Spread fingers apart
- Decrease volume: Bring fingers closer
- The current volume percentage will be displayed on the screen.
- Press
qto exit.
- The script captures video from the webcam.
- It detects hand landmarks using Mediapipe Hands.
- If the index finger tip and thumb tip are inside the predefined green box, their distance is calculated.
- This distance is mapped to the system volume range using Pycaw.
- The volume is updated in real-time based on finger movements.
- Improve hand tracking accuracy
- Add gesture-based mute/unmute functionality
- Extend support for other media controls (e.g., play/pause)
Feel free to fork this repository and submit pull requests. Contributions are welcome!
MIT License. See LICENSE for details.