This project is a virtual mouse system that uses hand gestures to control the mouse cursor. It uses a webcam to capture video, detects hand landmarks, and moves the mouse cursor based on the detected hand movements. Additionally, it supports clicking using thumb and index finger pinching gestures.
The Virtual Mouse project leverages computer vision and machine learning techniques to enable mouse control through hand gestures. It uses the webcam to capture video, processes the frames to detect hand landmarks, and moves the mouse cursor accordingly. The index finger tip controls the cursor movement, and the thumb tip in conjunction with the index finger tip enables clicking actions.
To install the necessary modules, follow these steps:
-
Clone the repository:
git clone https://github.com/your_username/virtual_mouse.git
-
Navigate to the project directory:
cd virtual_mouse -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required modules:
pip install -r requirements.txt
Alternatively, you can install the modules individually:
pip install opencv-contrib-python
pip install numpy
pip install mediapipe
pip install pyautogui
pip install matplotlib- Ensure you are in the project directory and the virtual environment is activated.
- Run the application:
python main.py
-
cv2 (OpenCV): Used for real-time computer vision. It captures video from the webcam and processes the frames.
- Installation:
pip install opencv-contrib-python
- Installation:
-
numpy: A fundamental package for scientific computing with Python. It is used here for numerical operations.
- Installation:
pip install numpy
- Installation:
-
mediapipe: A framework for building multimodal (e.g., video, audio, and sensor) applied ML pipelines. Used for hand landmark detection.
- Installation:
pip install mediapipe
- Installation:
-
pyautogui: A module for programmatically controlling the mouse and keyboard. It is used to move the mouse cursor and simulate mouse clicks.
- Installation:
pip install pyautogui
- Installation:
-
matplotlib: A plotting library for the Python programming language and its numerical mathematics extension NumPy. Here, it is used to visualize data if needed.
- Installation:
pip install matplotlib
- Installation:
- Real-time hand detection and tracking.
- Mouse cursor control using index finger tip.
- Mouse clicking using thumb and index finger pinching gestures.
- Smooth cursor movement.
