Skip to content

This project was built with python. here is features that this project provides: Mouse Controller, Screen brightness adjustment

Notifications You must be signed in to change notification settings

TahaCodeHub/Control-Mouse-With-Hand-Tracking-In-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Hand Gesture Control System

A Python-based application that allows you to control your computer's mouse and adjust screen brightness using hand gestures captured through your webcam.

Features

  • Mouse Control: Move the cursor by moving your hand in front of the camera
  • Click Gestures:
    • Left-click: Bend your index finger
    • Double-click: Index and middle fingers close together with thumb raised
    • Right-click: Thumb and pinky close together
    • Drag: Thumb and index finger very close together
  • Brightness Adjustment: Automatically adjusts screen brightness based on ambient lighting
  • Show Desktop: Raise all fingers to show the desktop (Windows key + D)

Requirements

  • Python 3.7+
  • OpenCV
  • MediaPipe
  • PyAutoGUI
  • Screen Brightness Control
  • NumPy

Installation

  1. Clone the repository:

    git clone https://github.com/TahaCodeHub/Control-Mouse-With-Hand-Tracking-In-Python
    
  2. Install the required packages:

    pip install -r requirements.txt
    

Usage

  1. Run the script:

    python SHMD.py
    
  2. A window will appear showing your webcam feed with hand landmarks drawn on it.

  3. Use the following gestures to control your computer:

    • Move your hand to move the cursor
    • Bend your index finger for left-click
    • Bring index and middle fingers close together with thumb raised for double-click
    • Bring thumb and pinky close together for right-click
    • Bring thumb and index finger very close together to drag
    • Raise all fingers to show desktop
  4. Press 'q' to exit the application.

How It Works

The application uses MediaPipe to detect hand landmarks from the webcam feed. These landmarks are then processed to recognize specific gestures, which are translated into mouse and keyboard actions using PyAutoGUI. The screen brightness is adjusted based on the average brightness of the camera frames.

Configuration

You can adjust the following parameters in the code:

  • smoothing: Controls mouse movement smoothness (default: 0.75)
  • scaling_factor: Adjusts hand movement sensitivity (default: 1.5)
  • brightness_interval: How often to check and adjust brightness (default: 10 frames)

Troubleshooting

  • If the camera doesn't work, make sure it's not being used by another application.
  • For better performance, ensure good lighting conditions.
  • If mouse control is too sensitive or not sensitive enough, adjust the scaling_factor parameter.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • MediaPipe for hand tracking
  • OpenCV for image processing
  • PyAutoGUI for system control

About

This project was built with python. here is features that this project provides: Mouse Controller, Screen brightness adjustment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages