This project allows you to control your computer mouse using hand gestures captured through your webcam.
# Create a virtual environment
python -m venv venv
# Activate the virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install all required packages
pip install -r requirements.txt
python main.py
Position your hand in front of the webcam and use the following gestures:
-
Move Cursor: Raise your index finger and keep other fingers down.
- The cursor will follow the movement of your index finger.
-
Click: Raise both index and middle fingers and bring them close together.
- When the distance between the fingers is less than 40 pixels, a click is performed.
-
Drag and Drop:
- Start Drag (Mouse Down): Raise thumb and index finger and bring them close together.
- End Drag (Mouse Up): Raise middle and ring fingers while keeping index finger down.
-
Pause/Resume Control: Press the "]" key to toggle pause/resume of mouse events.
Works well with:
- Games like Fruit Ninja: https://poki.com/en/g/fruit-ninja
- Drawing applications like Paint
- Make sure your hand is within the purple boundary box displayed on the screen for optimal tracking.
- The frame rate (FPS) is displayed in the top-left corner of the window.
- For best results, use in a well-lit environment with a clear background.
- The application uses your default webcam (index 0).