Skip to content

Control your computer mouse with hand gestures using your webcam! This script uses OpenCV, MediaPipe, and PyAutoGUI to detect hand landmarks and simulate mouse movements and clicks. Simply install the required libraries, run the script, and interact with your computer

License

Notifications You must be signed in to change notification settings

PierpaoloGonnella/Vision-Mouse-AI

Repository files navigation

Vision-Mouse-AI

This script enables control of the computer mouse using hand gestures detected through a webcam. It utilizes the following technologies:

  • OpenCV (cv2): For capturing video from the webcam and processing frames.
  • MediaPipe (mediapipe): To detect hand landmarks in real-time.
  • PyAutoGUI: For controlling the mouse cursor and simulating clicks.

Requirements

  • Python 3.x
  • Libraries: cv2, mediapipe, pyautogui

Setup and Usage

  1. Install Dependencies:

pip install opencv-python mediapipe pyautogui

  1. Run the Script:

  2. Hand Gestures:

  • Right Hand:
    • Cursor Movement: Use the central point between wrist and middle finger MCP.
    • Left Click: Bring thumb and index finger close (within 50 pixels).
  • Left Hand:
    • Right Click: Bring thumb and index finger close (within 50 pixels).
  1. Keyboard Commands:
  • Press 'q' to exit the program.

Functionality

  • The script initializes the webcam and detects hand landmarks using MediaPipe.
  • It calculates the central point of the hand for mouse cursor control.
  • Hand gestures are interpreted to perform left and right clicks using PyAutoGUI.
  • Optionally, it displays the webcam feed with overlaid hand landmarks.

Notes

  • Adjust min_detection_confidence in mp.solutions.hands.Hands for better landmark detection as per lighting conditions.
  • Ensure proper lighting and clear hand visibility for optimal performance.

About

Control your computer mouse with hand gestures using your webcam! This script uses OpenCV, MediaPipe, and PyAutoGUI to detect hand landmarks and simulate mouse movements and clicks. Simply install the required libraries, run the script, and interact with your computer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published