A Python project to control your computer mouse using hand gestures. Built using MediaPipe, OpenCV, and ctypes, this script enables real-time control of cursor movement and basic mouse operations like left click, right click, and dragging using finger gestures.
- 👉 Move cursor using index finger
- 🧿 Left click: Thumb + Index pinch
- ✌️ Right click: Index + Middle pinch
- 📌 Drag: Pinch and hold (Thumb + Index)
- 📺 Real-time webcam input and gesture visualization
-
Python 3.8 or later
-
Windows OS
-
Libraries:
- opencv-python
- mediapipe
- numpy
Install dependencies :
pip install opencv-python mediapipe numpy- Clone the repository
- Go inside the directory
- Run the main script :
python main.py- Use gestures in front of your webcam to control the mouse
- Press Q to quit the application
- Uses MediaPipe Hands to detect 21 hand landmarks
- Tracks finger positions and calculates distances between key fingers
- Maps hand movement to screen coordinates with smoothing
- Performs mouse actions using
ctypes.windll.user32
| Gesture | Action |
|---|---|
| Index finger move | Move Cursor |
| Thumb + Index pinch | Left Click |
| Index + Middle pinch | Right Click |
| Hold Thumb + Index | Drag & Drop |
This project is open source and free to use for educational and personal projects.