This project implements a virtual mouse that can be controlled using hand gestures. It leverages computer vision techniques and machine learning models provided by MediaPipe to detect and interpret hand movements, allowing you to control your computer's cursor and perform various actions using gestures.
- Hand Gesture Recognition: Detects various hand gestures such as fist, open palm, and specific finger movements.
- Cursor Control: Moves the cursor based on hand position.
- Gesture-Based Actions:
- Fist: Click and drag.
- Two fingers closed: Double click.
- Pinch: Scroll and adjust system volume/brightness.
- Specific finger gestures for right-click and other actions.
- Graphical User Interface (GUI): A user-friendly interface to start and stop the gesture recognition.
-
Clone the repository:
git clone https://github.com/yourusername/virtual-mouse-gesture-controller.git cd virtual-mouse-gesture-controller
-
Install the required packages:
pip install -r requirements.txt
Ensure the following libraries are installed:
- OpenCV
- MediaPipe
- PyAutoGUI
- Math
- Enum
- Pycaw
- Google Protobuf
- Screen Brightness Control
- Pynput
- Tkinter
- PIL (Pillow)
-
Run the application:
python main.py
-
Using the GUI:
- A window will appear with a button labeled "Track Mouse". Click this button to start the gesture recognition.
- You can also press the
Enter
key to start the gesture recognition.
-
Performing gestures:
- Move your hand in front of the camera to control the cursor.
- Use specific gestures to perform actions like clicking, dragging, scrolling, and adjusting volume/brightness.
- Fist: Click and drag.
- Two Fingers Closed: Double click.
- Pinch:
- Horizontal pinch: Scroll horizontally.
- Vertical pinch: Scroll vertically.
- V Gesture: Move cursor.
- Index Finger: Right-click.
- Middle Finger: Single click.
- Colors: You can customize the colors for fingertip and hand landmarks by modifying the
TIPCOLOR
andHANDCOLOR
variables. - Camera Settings: Adjust camera resolution and frame settings in the
GestureController
class.
- GestureController Class: Manages the initialization and processing of hand gestures using MediaPipe.
- HandRecog Class: Recognizes and encodes hand gestures based on landmark positions.
- Controller Class: Maps gestures to system controls (mouse movements, clicks, scrolls, volume, and brightness adjustments).
- GUI: Built using Tkinter, providing a simple interface to start and stop gesture recognition.
- Ensure your webcam is properly connected.
- Make sure you have all required libraries installed.
- Adjust the lighting in your environment for better hand detection accuracy.
Feel free to fork this repository, create new features, fix bugs, or improve the documentation. Pull requests are welcome!
This project is licensed under the MIT License. See the LICENSE file for details.