A real-time hand gesture recognition system built with Python, MediaPipe, OpenCV, and PyAutoGUI that transforms your webcam into a virtual mouse, presentation remote, and game controller.
Gesture Based Controller is a computer vision project that allows users to control their computer without touching a mouse or keyboard.
Using a webcam, the system detects hand landmarks in real time and converts predefined gestures into mouse movements and keyboard shortcuts.
The project supports three operating modes:
- ๐ฅ Desktop Control
- ๐ค Presentation Control
- ๐ฎ Game Control
- ๐ฑ Cursor Movement
- ๐ Left Click
- ๐๐ Right Click (Double Pinch)
- ๐ Scroll Up
- ๐ Scroll Down
- ๐ Alt + Tab Application Switcher
- ๐ Ctrl + Tab Browser Switching
- โจ Press Enter
Control presentations without touching the keyboard.
- ๐ Swipe Right โ Next Slide
- ๐ Swipe Left โ Previous Slide
- โ Open Palm โ Start Slideshow (F5)
- โ Closed Fist โ Exit Slideshow (Esc)
Play arrow-key based games using gestures.
| Gesture | Keyboard Action |
|---|---|
| โ Index Finger | Right Arrow |
| โ Peace Sign | Left Arrow |
| ๐ Open Palm | Up Arrow (Jump) |
| โ Closed Fist | Down Arrow (Duck) |
Works great with games like:
- Subway Surfers
- Temple Run
- Chrome Dino
- Any Arrow-Key Based Game
Raise only your Pinky Finger for 1 second to switch between modes.
Desktop
โ
Presentation
โ
Game
โ
Desktop
- Python
- OpenCV
- MediaPipe Tasks API
- PyAutoGUI
- NumPy
git clone https://github.com/manisbhusal/Gesture-Based-Controller.git
cd Gesture-Based-Controllerpython -m venv .venv
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activatepython -m pip install opencv-python
pip install opencv-python mediapipe pyautogui numpy`` If pip isn't found
Install it first:
sudo apt update
sudo apt install python3-pip
---
## 4. Run the Project
```bash
python gesture.py`` If you're using a virtual environment (recommended)
Create one:
python3 -m venv .venv
Activate it:
source .venv/bin/activate
Then install everything:
pip install opencv-python mediapipe pyautogui numpy
Run your program:
python gesture.pyThe MediaPipe hand tracking model will automatically download during the first execution.
Press Q to quit.
| Gesture | Action |
|---|---|
| โ Index Finger | Move Cursor |
| ๐ค Pinch | Left Click |
| ๐ค๐ค Double Pinch | Right Click |
| โ Index + Middle | Scroll Up |
| โ Closed Fist | Scroll Down |
| ๐ Four Fingers | Alt + Tab |
| ๐ค Middle + Ring + Pinky | Ctrl + Tab |
| ๐ค Index + Middle + Ring | Enter |
| Gesture | Action |
|---|---|
| ๐ Swipe Right | Next Slide |
| ๐ Swipe Left | Previous Slide |
| ๐ Open Palm | Start Presentation |
| โ Closed Fist | Exit Presentation |
| Gesture | Keyboard |
|---|---|
| โ Index | Right Arrow |
| โ Peace | Left Arrow |
| ๐ Open Palm | Up Arrow |
| โ Closed Fist | Down Arrow |
- โ Cursor Smoothing
- โ Dynamic Hand Scaling
- โ False Gesture Protection
- โ Gesture Cooldowns
- โ Double Pinch Detection
- โ Swipe Detection
- โ Gesture Latching
- โ Automatic MediaPipe Model Download
Gesture-Based-Controller/
โ
โโโ gesture.py
โโโ README.md
โโโ requirements.txt
โโโ hand_landmarker.task
- Python 3.10+
- Webcam
- Windows, Linux or macOS
Note: Windows provides the best compatibility with PyAutoGUI. On Linux, using X11 is recommended instead of Wayland.
- Use a well-lit environment.
- Keep only one hand visible.
- Position your webcam directly in front of you.
- Avoid cluttered backgrounds.
- Maintain a consistent distance from the camera.
- Multi-Hand Support
- Volume Controller
- Brightness Controller
- Media Controls
- Drag & Drop
- Virtual Keyboard
- Custom Gesture Training
- AI Gesture Recognition
- Voice + Gesture Hybrid Control
- Settings GUI
- User Profiles
Contributions are welcome!
-
Fork this repository
-
Create a new branch
git checkout -b feature-name- Commit your changes
git commit -m "Add new feature"- Push your branch
git push origin feature-name- Open a Pull Request.
- Requires adequate lighting.
- Supports only one hand.
- Extremely fast hand movements may not be detected.
- Webcam quality directly affects tracking accuracy.
- Some keyboard shortcuts may differ between operating systems.
- PyAutoGUI has limited support on Wayland (Linux).
This project is licensed under the MIT License.
Feel free to use, modify, and distribute it.
Special thanks to:
- MediaPipe
- OpenCV
- PyAutoGUI
- NumPy
- Python Community