Skip to content

About

Volume-Control-Using-Computer-Vision is a type of software in which the device volume can be controlled using the thumb and first finger as it use cv2 module and detects the hand.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Here's a README file for your project that explains the trackingmodule.py and volumecontrol.py files:


Hand Tracking and Volume Control

Overview

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.

Files

1. trackingmodule.py

This module implements hand detection and landmark extraction using the MediaPipe library.

Dependencies

  • cv2 (OpenCV)
  • mediapipe
  • time

Class

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.

Usage

  1. Run the script to start hand tracking and display video with detected hand landmarks.

    python trackingmodule.py
  2. Press 'q' to exit the video window.

2. volumecontrol.py

This script uses hand tracking to control the system volume based on the distance between the thumb and index finger.

Dependencies

  • cv2 (OpenCV)
  • numpy
  • handtrackingmodule (custom module)
  • math
  • pycaw (Python Core Audio Windows)

Functionality

  • Webcam Setup: Initializes the webcam and sets resolution.
  • Hand Detection: Uses handDetector from trackingmodule.py to track hand landmarks.
  • Volume Control: Maps the distance between the thumb and index finger to system volume levels using the pycaw library.

How to Run

  1. Ensure you have the required dependencies installed:

    pip install opencv-python numpy pycaw
  2. Run the script to start hand tracking and control the volume:

    python volumecontrol.py
  3. 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.

  4. Press 'd' to stop the video stream and exit.

License

This project is licensed under the MIT License.

Acknowledgements

  • 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!

About

Volume-Control-Using-Computer-Vision is a type of software in which the device volume can be controlled using the thumb and first finger as it use cv2 module and detects the hand.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages