Skip to content

bethvourc/mouse_move

Repository files navigation

AI Virtual Mouse

AI Virtual Mouse is a Python application that enables controlling the mouse cursor with hand gestures captured via a webcam.
It leverages MediaPipe Hands for landmark detection, OpenCV for video processing, and PyAutoGUI for system-level mouse control.

Features

  • Real-time hand detection and landmark tracking with MediaPipe
  • Cursor movement mapped to index finger tip position
  • Gesture-based controls:
    • Move Cursor → move index finger
    • Left Click → pinch index finger & thumb together
    • Right Click → pinch middle finger & thumb
    • Scroll Up/Down → vertical hand gestures
  • Multi-hand support (detects left vs right hand)
  • Configurable gesture mapping for customization

Requirements

Install them with:

pip install opencv-python mediapipe pyautogui numpy

Usage

  1. Clone the repository:

    git clone https://github.com/yourusername/ai-virtual-mouse.git
    cd ai-virtual-mouse
  2. Run the application:

    python main.py
  3. Place your hand in view of the webcam:

    • Move your index finger → cursor moves
    • Pinch index & thumb → left click
    • Pinch middle & thumb → right click
    • Move hand up/down with open palm → scroll
  4. Press q to quit.

Configuration

  • Sensitivity, smoothing, and gesture mappings can be adjusted in config.py.
  • Debug overlays (landmarks, FPS, gesture labels) can be enabled by setting draw_landmarks=True when initializing HandTracker.

Project Structure

ai_virtual_mouse/
├── main.py                # Entry point
├── hand_tracker.py        # MediaPipe hand detection wrapper
├── gesture_classifier.py  # Maps landmarks → gestures
├── mouse_controller.py    # Handles PyAutoGUI mouse actions
├── utils/                 # Helper functions
└── tests/                 # Unit & E2E tests

Limitations

  • Requires consistent lighting and clear webcam view of hands.
  • Latency may increase on low-end hardware.
  • Currently optimized for single-user interaction.

Contributions

Contributions are welcome!

  • Fork the repo
  • Create a feature branch
  • Submit a pull request

Built using Python, MediaPipe, OpenCV, and PyAutoGUI.

About

Virtual Mouse

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors