Virtual Mouse is a Python application that enables users to control their computer's mouse cursor using hand gestures detected via a webcam. This project utilizes MediaPipe for hand tracking and PyAutoGUI for simulating mouse movements and clicks. The application focuses on providing an intuitive way to navigate and interact with a computer interface without the need for a physical mouse.
- Hand tracking using MediaPipe.
- Control mouse cursor movements with hand gestures.
- Perform left, right, and double-clicks using specific gestures.
- Take screenshots using a designated gesture.
- Adjustable gesture sensitivity and recognition thresholds.
- Python 3.x
- OpenCV
- MediaPipe
- PyAutoGUI
- pynput
- numpy
-
Clone the repository:
git clone https://github.com/yourusername/virtual-mouse.git cd virtual-mouse
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
virtualMouse.ipynb
: Jupyter notebook containing the main application logic and gestures for controlling the mouse.util.py
: Utility functions used within the application for gesture recognition and processing.
-
Run the application:
python virtualMouse.ipynb
-
Allow the application to access your webcam. Ensure you are in front of the camera and that your hand gestures are visible.
-
Use the following gestures to control the mouse:
- Move cursor: Position your index finger in the camera view.
- Left Click: Pinch your thumb and index finger together.
- Right Click: Extend your thumb and pinch your index finger.
- Double Click: Quickly pinch your thumb and index finger twice.
- Screenshot: Pinch your thumb and index finger and hold for a moment.