This project implements a virtual mouse using hand gestures detected via a webcam. It uses OpenCV for video processing, MediaPipe for hand tracking and finger detection, and PyAutoGUI for controlling the mouse.
The Virtual Mouse project enables users to control their computer's mouse pointer using hand gestures captured by the webcam. This innovative approach to human-computer interaction can be particularly useful for presentations, accessibility, and hands-free control of a computer. I have implemented this project to learn the concepts and impact of OpenCV
- Real-time hand-finger detection using MediaPipe
- Smooth cursor movement with OpenCV
- Click actions based on the distance between the thumb and index finger
- Easy-to-setup and use
- Python 3.x
- OpenCV
- MediaPipe 3.20.x
- PyAutoGUI
- Clone the repository:
git clone https://github.com/anirxudh/VirtualMouse.git
- Navigate to the project directory:
cd virtual-mouse
- Install the required packages:
pip install opencv-python pip install mediapipe 3.20.0 pip install PyAutoGUI
- Run the virtual mouse script:
python EzCursor.py
- Use your hand gestures in front of the webcam to control the mouse pointer.
- For simple cursor control use your index finger and for clicks one may use pick gesture(thumb and index finger are close)
The application uses the following steps to function:
- Capture Video: The webcam captures video frames in real-time.
- Hand Detection: MediaPipe processes each frame to detect hand landmarks.
- Gesture Recognition: Specific landmarks (index finger tip and thumb tip) are identified.
- Cursor Movement: The position of the index finger tip is mapped to the screen coordinates to move the cursor.
- Click Detection: The distance between the thumb tip and index finger tip is calculated to determine click actions.
- OpenCV: Used for capturing video frames and processing images.
- MediaPipe: Used for detecting and tracking hand landmarks.
- PyAutoGUI: Used for controlling the mouse pointer and performing click actions.
- Numpy: Used for efficient numerical operations and smoothing cursor movements.
Contributions are welcome! Please fork this repository and submit pull requests.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request