This project uses the MediaPipe library to detect hands and control the system volume through finger gestures. Detection is performed via the webcam and adjusts the volume based on the distance between the thumb and index finger.
Requirements
- Python 3.7+
- OpenCV
- MediaPipe
- NumPy
- pycaw
- comtypes
- Clone this repository:
git clone https://github.com/brianrscode/hand-volume-control.git
cd hand-volume-control
- Install the dependencies:
pip install -r requirements.txt
- Run the main script:
python main.py
- Make sure your webcam is on and visible.
- Adjust the volume by bringing the thumb and index finger together and moving them apart or closer.
-
HandsDetector.py
: Contains the HandsDetector class for hand detection and tracking using MediaPipe. -
main.py
: Main script to run hand detection and volume control.
The HandsDetector
class provides methods to:
- Detect hands in a video frame.
- Find positions of hand landmarks.
- Determine which fingers are up.
- Calculate the distance between two specific landmarks.
The main script:
- Sets up video capture from the webcam.
- Uses the
HandsDetector
class to detect hands and get landmark positions. - Calculates the distance between the thumb and index finger to adjust the system volume.