A Python-powered Virtual Mouse that enables you to control your computer cursor using just hand gestures detected via a webcam. No physical mouse required!
- 🖱️ Cursor Movement — Move the mouse by moving your index finger.
- 👈 Left Click — Touch thumb tip and index finger tip to click.
- 👉 Right Click — Touch thumb tip and middle finger tip to right-click.
- 🔃 Scroll Up — Touch thumb tip and ring finger tip (top) to scroll up one viewport.
- 🔽 Scroll Down — Touch thumb tip and ring finger base to scroll down one viewport.
- 🖐️ Drag & Drop — Bring thumb tip near index base and hold for 2 seconds to start dragging. Release fingers to drop.
- Python 3.x
- OpenCV — Computer vision for webcam input.
- MediaPipe — Real-time hand landmark detection.
- PyAutoGUI — GUI automation (mouse control).
The demo video file (Virtual Mouse Project Video.mp4) is included in this repository.
Since the file size is large, GitHub might not preview it directly in the browser.
- Click the "🔽" (Down arrow) button at the top-right corner of the file list (beside the pencil/edit icon).
- Select "Open in github.dev".
- In GitHub.dev, locate the
Virtual Mouse Project Video.mp4file and click it to play.
Alternatively, you can download the file directly to view it on your device.
-
Clone this repository:
git clone https://github.com/your-username/virtual-mouse.git cd virtual-mouse -
Install dependencies:
pip install opencv-python mediapipe pyautogui
-
Run the script:
python virtual_mouse.py
-
Show your hand in front of the camera and control the mouse!
- Run in a well-lit environment for best hand tracking.
- Webcam required.
- Avoid sudden hand movements to reduce lag.
- Adjust distance thresholds in the script for your comfort.
- Multi-hand support.
- Gesture customization via UI.
- Voice command integration.
- Inspired by tutorials and docs from OpenCV, MediaPipe, and PyAutoGUI communities.
- Special thanks to Google for MediaPipe framework.
This project is licensed under the MIT License.