Coder Social home page Coder Social logo

eswarpranavnadhhari / volumecontrolusinghandgesture Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3 KB

This Python script allows you to control the system volume using hand gestures captured through your computer's webcam. It utilizes OpenCV (cv2) for capturing webcam frames, Mediapipe for hand tracking, and pycaw for adjusting the system volume.

Python 100.00%

volumecontrolusinghandgesture's Introduction

Hand Gesture Volume Control

This Python script allows you to control the system volume using hand gestures captured through your computer's webcam. It utilizes OpenCV (cv2) for capturing webcam frames, Mediapipe for hand tracking, and pycaw for adjusting the system volume.

Prerequisites

Before running the script, make sure you have the following libraries installed:

  • OpenCV (cv2): You can install it using pip with the command:

    pip install opencv-python
    
  • Mediapipe: Install it using pip:

    pip install mediapipe
    
  • pycaw: To control the system volume, you'll need pycaw. Install it with pip:

    pip install pycaw
    

Usage

  1. Run the script by executing it with Python. It will capture video from your default webcam (cap = cv2.VideoCapture(0)).

  2. Raise your hand in front of the camera, and the script will detect your hand landmarks and track their movement.

  3. Pinch your thumb and index finger together to control the volume. The distance between these two fingers determines the volume level. Move them apart or closer to change the volume.

  4. The script will display the volume level and length between your fingers in the terminal.

  5. To exit the script, press 'q' in the OpenCV window.

Adjusting Volume Range

  • You can customize the hand gesture range for volume control by modifying the following line:

    vol = np.interp(length, [15, 220], [volMin, volMax])

    Adjust the values [15, 220] to set the hand gesture range for volume control. For example, you can increase the 220 value to make the volume gesture require a larger hand movement.

  • The volume range is also adjustable:

    # Volume range -63.5 (mute) to 0.0 (max volume)

Compatibility

This script should work on Windows operating systems as it relies on pycaw for volume control. Ensure that you have an active webcam and the required Python libraries installed.

volumecontrolusinghandgesture's People

Contributors

eswarpranavnadhhari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.