Skip to content

mrithip/ai-virtual-mouse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Virtual Mouse

AI Virtual Mouse is a computer vision-based project that allows users to control their system cursor using hand gestures captured through a webcam. It uses MediaPipe for hand tracking and PyAutoGUI for cursor control.


Features

  • Real-time hand tracking
  • Cursor movement using index finger
  • Click action using pinch gesture (thumb and index finger)
  • Lightweight and responsive
  • No physical mouse required

Technologies Used

  • Python
  • OpenCV
  • MediaPipe (Tasks API)
  • PyAutoGUI

Installation

1. Clone the repository

git clone https://github.com/your-username/ai-virtual-mouse.git
cd ai-virtual-mouse

2. Install dependencies

pip install opencv-python mediapipe pyautogui

3. Download the model file

Download the MediaPipe Hand Landmarker model file:

  • Filename: hand_landmarker.task
  • Place it in the root directory of the project

Usage

Run the script using:

python main.py

Controls

Gesture Action
Index finger Move cursor
Thumb + index (pinch) Left click
Press 'Q' Exit program

How It Works

  1. The webcam captures live video.
  2. MediaPipe detects 21 hand landmarks.
  3. The index finger tip is mapped to screen coordinates.
  4. Distance between thumb tip and index tip is calculated.
  5. A click is triggered when the distance goes below a threshold.

Project Structure

ai-virtual-mouse/
│
├── main.py
├── hand_landmarker.task
└── README.md

Configuration

You can adjust click sensitivity by modifying:

if distance < 0.06:
  • Lower value increases precision (harder to click)
  • Higher value makes clicking easier

Notes

  • Ensure proper lighting conditions
  • Keep your hand clearly visible in the frame
  • Avoid cluttered backgrounds for better detection
  • On some systems, screen control permissions may be required

Future Improvements

  • Right-click gesture
  • Scrolling support
  • Multi-hand tracking
  • Gesture customization
  • Graphical user interface

License

This project is open-source and available under the MIT License.

About

Real-time AI-powered virtual mouse using hand tracking. Uses MediaPipe landmarks to map finger movement to screen coordinates and detect pinch gestures for click actions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages