A Python-based application that allows you to control your computer's mouse and adjust screen brightness using hand gestures captured through your webcam.
- 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)
- Python 3.7+
- OpenCV
- MediaPipe
- PyAutoGUI
- Screen Brightness Control
- NumPy
- 
Clone the repository: git clone https://github.com/TahaCodeHub/Control-Mouse-With-Hand-Tracking-In-Python
- 
Install the required packages: pip install -r requirements.txt
- 
Run the script: python SHMD.py
- 
A window will appear showing your webcam feed with hand landmarks drawn on it. 
- 
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
 
- 
Press 'q' to exit the application. 
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.
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)
- 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_factorparameter.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- MediaPipe for hand tracking
- OpenCV for image processing
- PyAutoGUI for system control