Control your computer mouse using just your hand! This project uses OpenCV, MediaPipe, and PyAutoGUI to detect hand gestures in real-time and perform mouse actions such as cursor movement, clicking, double-clicking, and taking screenshots.
- Move the mouse cursor using your index finger
- Left Click
- Right Click
- Double Click
- Take Screenshot using a hand gesture
- Real-time gesture recognition
- Webcam-based interaction (No additional hardware required)
- More can be added as well
- Python
- OpenCV
- MediaPipe
- NumPy
- PyAutoGUI
- pynput
Virtual-Mouse/
│
├── main.py # Main application
├── util.py # Helper functions (angle & distance calculations)
├── requirements.txt
├── README.md
└── screenshots/
- The webcam captures live video.
- MediaPipe detects 21 hand landmarks.
- The project calculates:
- Finger joint angles
- Distance between thumb and index finger
- Different gesture combinations are mapped to mouse operations.
- PyAutoGUI and pynput execute the corresponding mouse events.
| Gesture | Action |
|---|---|
| Index finger extended + Middle finger extended + Thumb close | Move Cursor |
| Index finger bent | Left Click |
| Middle finger bent | Right Click |
| Index + Middle finger bent | Double Click |
| Open Palm Widely | Take Screenshot |
Note: Gesture detection is based on finger joint angles and thumb-index finger distance.
The project detects gestures by computing:
- Finger joint angles
- Euclidean distance between thumb and index finger
-
get_angle()- Calculates the angle between three hand landmarks.
-
get_distance()- Computes the Euclidean distance between two landmarks.
These values are used to determine which gesture is currently being performed.
git clone https://github.com/ak-junior3339/gesture-controlled-mouse.git
cd Virtual-Mousepip install -r requirements.txtpython main.pyPress Q to quit.
opencv-python
mediapipe
numpy
pyautogui
pynput
Install manually if needed:
pip install opencv-python mediapipe numpy pyautogui pynput- Smooth cursor movement using interpolation
- Drag and Drop gesture
- Scroll gesture
- Volume control
- Brightness control
- Multi-hand support
- Custom gesture training
- Gesture calibration for different users
Contributions are welcome!
- Fork the repository
- Create a new branch
git checkout -b feature-name- Commit your changes
git commit -m "Add new feature"- Push the branch
git push origin feature-name- Open a Pull Request
Give this repository a ⭐ on GitHub. It helps others discover the project and motivates further development!
Aishwarya Kumar Singh
Passionate about Machine Learning, Deep Learning, Computer Vision, and AI-powered applications.
LinkedIn: https://www.linkedin.com/in/aishwarya-kumar-singh-244a93269/