πŸ€– LateAI
Home β€Ί Tutorials β€Ί AI Virtual Mouse
πŸ–±οΈ

AI Virtual Mouse

Beginner Β· 2-3 hours
πŸ“Ά Beginner ⏱ 2-3 hours πŸ’° Free (software only) 🏷 CV Zone

πŸ“Œ Overview

Control your computer with a wave of your hand: the index fingertip moves the cursor, bringing the index and middle fingers together clicks, and other finger gestures handle right-click and scrolling.

It combines hand tracking (MediaPipe's 21 points) with desktop automation (pyautogui) - the classic demonstration of computer vision driving desktop automation.

🧰 What you need

πŸ”§ Step by step

1

Install the dependencies

pyautogui handles moving the mouse and clicking

Some systems need accessibility permission before a program may control the mouse

2

Detect the hand

Reuse HandTrackingModule to find the hand landmarks

Get the coordinates of the index and middle fingertips

3

Map the coordinates

Map camera frame coordinates onto your screen resolution

Use a proportional linear mapping and smooth it to cut down jitter

4

Move the cursor

The index fingertip position drives the mouse

Use pyautogui.moveTo and mind the speed and smoothing factor

5

Click gesture

Treat it as a click when the index and middle fingers are closer than a threshold

Simulate the click with pyautogui.click and add a debounce delay to avoid accidental clicks

6

Extend the controls

Add more gestures: right-click, double-click, drag, and scroll

Wrap the gesture-to-action mapping in a table so it is easy to customise

πŸ’‘ Tips

View original β†— ← Back to LateAI home