Skip to content

This project uses computer vision to control the mouse cursor with hand gestures, eliminating the need for a physical mouse. Built with Python, OpenCV, and MediaPipe, it tracks hand landmarks via webcam and translates gestures into cursor movement and click actions. Ideal for hands-free control or accessibility solutions.

Notifications You must be signed in to change notification settings

Pxdarkshadow/Virtual-Mouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–±οΈ Virtual Mouse using OpenCV and Hand Tracking

A Python-based virtual mouse that lets you control your computer cursor with hand gestures using your webcam. This project utilizes OpenCV for image processing, MediaPipe for real-time hand tracking, and PyAutoGUI to simulate mouse actions.

Demo Screenshot

Screenshot 2025-04-28 213314

✨ Features

  • πŸ–οΈ Hand tracking with high accuracy using MediaPipe
  • πŸ–±οΈ Cursor movement using index finger
  • πŸ‘† Left click with index + middle finger pinch
  • 🀏 Right click with index + ring finger pinch
  • πŸ”„ Extendable for scroll and drag gestures

πŸ› οΈ Tech Stack

  • Python 3.8+
  • OpenCV – for video capture and processing
  • MediaPipe – for hand landmark detection
  • PyAutoGUI – for mouse control

πŸ“¦ Requirements

You can install all dependencies with:

pip install -r requirements.txt
pip install opencv-python mediapipe pyautogui

πŸš€ How to Run

  1. Clone the Repository
git clone https://github.com/yourusername/virtual-mouse-opencv.git
cd virtual-mouse-opencv
  1. Run the Script
python virtual_mouse.py

Make sure your webcam is connected and accessible.


βœ‹ How it Works

  • The webcam feed is processed frame by frame using OpenCV.

  • MediaPipe detects and tracks 21 hand landmarks.

  • Coordinates of the index finger tip are used to move the cursor.

  • Distance between specific fingers determines click actions:

    • Left Click: Pinch index and middle fingers
    • Right Click: Pinch index and ring fingers

πŸ“‚ Project Structure

virtual-mouse/
β”‚
β”œβ”€β”€ virtual_mouse.py       # Main Python script
β”œβ”€β”€ README.md              # Project readme 
β”œβ”€β”€ requirements.txt       # Python package dependencies
└── screenshots/        

πŸ“Έ Demo

Watch the original tutorial by Murtaza’s Workshop:

πŸ”— YouTube Video


πŸ™Œ Credits

Built based on the tutorial by Murtaza’s Workshop - Robotics and AI.


πŸ“„ License

This project is licensed under the MIT License. Feel free to use and modify for learning purposes.


πŸ“¬ Contact

If you have questions or improvements, feel free to raise an issue or contribute via pull request.


About

This project uses computer vision to control the mouse cursor with hand gestures, eliminating the need for a physical mouse. Built with Python, OpenCV, and MediaPipe, it tracks hand landmarks via webcam and translates gestures into cursor movement and click actions. Ideal for hands-free control or accessibility solutions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages