Hand Volume Control is a Human-Computer Interaction (HCI) project that enables contactless audio management using computer vision. By leveraging OpenCV and MediaPipe, this application tracks hand landmarks in real-time to translate physical gestures into system volume commands.
This project eliminates the need for physical peripherals, offering a seamless and futuristic way to interact with media devices.
- Real-Time Tracking: Low-latency hand detection and landmark tracking.
- Gesture Recognition: Intuitive mapping of vertical hand movements to volume levels.
- Mute Toggle: Quick "Fist" gesture recognition for instant muting/unmuting.
- Cross-Platform Architecture: Designed for Windows (via Pycaw) with adaptable architecture for macOS/Linux.
- Configurable Sensitivity: User-defined sensitivity thresholds via a JSON configuration file.
- Language: Python 3.8+
- Computer Vision: OpenCV (
cv2), MediaPipe - Audio Control: Pycaw (Python Core Audio Windows Library)
- Math/Processing: NumPy
- Hardware:
- PC/Laptop with a working webcam (Integrated or USB).
- Software:
- Python 3.8 or higher installed.
-
Clone the Repository
git clone https://github.com/username/hand-volume-control.git cd hand-volume-control -
Set up a Virtual Environment (Optional but Recommended)
python -m venv venv # Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Application Execute the main script to start the webcam feed:
python hand_volume_control.py
-
Control Guide Ensure your hand is clearly visible in the camera frame (good lighting recommended).
| Gesture | Action | Description |
|---|---|---|
| Move Hand Up β¬οΈ | Volume UP | Raise your open hand vertically to increase volume. |
| Move Hand Down β¬οΈ | Volume DOWN | Lower your open hand vertically to decrease volume. |
| Clench Fist β | Mute / Unmute | Quickly close your hand into a fist to toggle audio. |
- Exit
Press
qorEscto close the application window.
You can fine-tune the tracking sensitivity and volume range by modifying the config.json file in the root directory.
{
"sensitivity": 0.5,
"camera_index": 0,
"volume_range": [0, 100],
"detection_confidence": 0.7
}- sensitivity: Adjusts the responsiveness of volume changes relative to hand movement speed.
- camera_index: Set to
0for default webcam,1for external, etc. - volume_range: Defines the min/max limits for the system volume.
- Camera Not Detected:
- Ensure no other application (Zoom, Teams, etc.) is currently using the webcam.
- Try changing the
camera_indexinconfig.json.
- Gestures Not Recognized:
- Ensure the environment is well-lit.
- Keep your hand within 0.5 - 1.0 meters of the camera.
- Audio Not Changing (Windows):
- Verify
pycawis installed correctly. - Run the script as Administrator if permission issues persist.
- Verify
Contributions are always welcome! If you have ideas for new gestures or platform support (macOS/Linux):
- Fork the Project.
- Create your Feature Branch (
git checkout -b feature/NewGesture). - Commit your Changes (
git commit -m 'Add some NewGesture'). - Push to the Branch (
git push origin feature/NewGesture). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
- MediaPipe by Google for the robust hand-tracking architecture.
- [Pycaw](https://github.com/ AndreMiras/pycaw) for the Windows audio control interface.
- OpenCV for image processing utilities.