Here's a README file for your project that explains the trackingmodule.py and volumecontrol.py files:
This project demonstrates hand tracking using a webcam to control the system volume based on hand gestures. The hand tracking is achieved with MediaPipe, and volume control is managed via the pycaw library.
This module implements hand detection and landmark extraction using the MediaPipe library.
cv2(OpenCV)mediapipetime
handDetector: A class for detecting and tracking hand landmarks.
- Methods:
__init__(self, mode=False, maxHands=2, detectionCon=0.5, modelComplexity=1, trackCon=0.5): Initializes the hand detection model with specified parameters.findHands(self, img, draw=True): Processes an image to detect hands and optionally draws landmarks on the image.findPosition(self, img, handNo=0, draw=True): Extracts the positions of hand landmarks and returns them as a list.
-
Run the script to start hand tracking and display video with detected hand landmarks.
python trackingmodule.py
-
Press 'q' to exit the video window.
This script uses hand tracking to control the system volume based on the distance between the thumb and index finger.
cv2(OpenCV)numpyhandtrackingmodule(custom module)mathpycaw(Python Core Audio Windows)
- Webcam Setup: Initializes the webcam and sets resolution.
- Hand Detection: Uses
handDetectorfromtrackingmodule.pyto track hand landmarks. - Volume Control: Maps the distance between the thumb and index finger to system volume levels using the
pycawlibrary.
-
Ensure you have the required dependencies installed:
pip install opencv-python numpy pycaw
-
Run the script to start hand tracking and control the volume:
python volumecontrol.py
-
Adjust the distance between your thumb and index finger to change the volume. The volume will be updated in real-time based on the gesture.
-
Press 'd' to stop the video stream and exit.
This project is licensed under the MIT License.
- OpenCV for computer vision functionalities.
- MediaPipe for hand tracking.
- pycaw for audio control on Windows.
Feel free to modify or expand upon any sections as needed for your project!