Skip to content

The system offers touch-free interaction for common mouse functions such as cursor movement, clicking, and scrolling.

Notifications You must be signed in to change notification settings

IcodeG00D/Virtual-Mouse-Using-Mediapipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Virtual Mouse Using Hand Gestures

Overview

This project implements a virtual mouse using hand gestures via your webcam. It uses MediaPipe for real-time hand tracking and PyAutoGUI to control the mouse, scroll, and click β€” all with your fingers. Ideal for touchless control or fun automation.


πŸ“Œ Features

  • Real-time hand tracking using MediaPipe
  • Control mouse cursor with your index finger
  • Scroll up/down with two fingers or fist gestures
  • Perform mouse click with all fingers extended
  • Exit using the β€œHang Loose” gesture πŸ€™ (thumb and pinky extended)
  • Uses gesture-based UI β€” no physical mouse required

🎯 Technologies Used

Library Purpose
cv2 (OpenCV) Captures video from webcam & visualizes output
mediapipe Detects and tracks hand landmarks
pyautogui Controls the mouse and keyboard
time Manages delays and debounce functionality

πŸ€– Why These Libraries?

  • MediaPipe: Lightweight and efficient ML framework by Google for hand/pose tracking.
  • PyAutoGUI: Easy-to-use Python library to control mouse and keyboard events.
  • OpenCV: For accessing camera feed and overlaying visual cues (like finger landmarks).
  • Time: Prevents rapid/unintended repeated actions (debounce logic).

βš™οΈ Setup Instructions

1. Clone the repository

git clone https://github.com/yourusername/virtual-mouse-gestures.git
cd virtual-mouse-gestures

2. Set up a virtual environment

python -m venv venv
venv\Scripts\activate   # On Windows

3. Install dependencies

pip install -r requirements.txt

requirements.txt should contain:

opencv-python
mediapipe
pyautogui

4. Run the program

python your_script_name.py

βœ‹ Gesture Mappings

Gesture Action
☝️ Index finger up Move mouse
✌️ Index + middle finger Scroll up
✊ Fist Scroll down
πŸ–οΈ All fingers extended Click
πŸ€™ Hang Loose (thumb + pinky) Exit program

πŸ“Œ Notes

  • Works best in well-lit environments.

  • Webcam resolution and frame rate affect performance.

  • Smoothing and debounce can be fine-tuned via constants:

    • SMOOTHING_FACTOR
    • DEBOUNCE_TIME

πŸ§ͺ Future Improvements

  • Add gesture for right-click or drag.
  • Include volume control or media gestures.
  • Show on-screen cursor overlay.
  • Use Kalman filter or AI-based stabilization for smoother movement.

About

The system offers touch-free interaction for common mouse functions such as cursor movement, clicking, and scrolling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages