This project is a real-time virtual mouse system built using Python, OpenCV, MediaPipe, and Autopy. It allows users to control their system's mouse cursor and perform click actions using hand gestures captured by a webcam.
- Tracks hand landmarks using MediaPipe
- Moves the mouse cursor with the index finger
- Performs left click when index and middle fingers are close together
- Works in real time with high accuracy and responsiveness
- Draws visual guides (cursor area and gesture feedback) on screen
- Python
- OpenCV
- MediaPipe
- Autopy (for controlling mouse cursor)
- NumPy
HandTrackingModule.py: Contains reusable hand detection class and gesture utilitiesmouse.py: Main application to control the virtual mouse using hand gestures
- The webcam captures real-time video input.
HandTrackingModule.pydetects hand landmarks using MediaPipe.- The system tracks the index finger to move the cursor across the screen.
- When both index and middle fingers are extended and close together, it performs a left click.
- Visual cues and gesture rectangles are shown to guide user interaction.
Run the following command to start the virtual mouse system:
python mouse.pyPress q to quit the program.
- Webcam
- Windows/macOS/Linux
- Python packages:
- opencv-python
- mediapipe
- autopy
- numpy
Install all dependencies:
pip install opencv-python mediapipe autopy numpyFor best accuracy, make sure your hand is well-lit and centered in the webcam view. Try different distances to see how movement sensitivity adjusts.