This project allows you to control games using hand gestures detected via a webcam. It uses OpenCV, MediaPipe, and PyAutoGUI to recognize finger positions and simulate keyboard presses.
-
Detects hand gestures in real-time using your webcam.
-
Maps specific gestures to game controls:
- Index finger up → Move Right (
→) - Index + Middle finger up → Move Left (
←) - Thumb + Index + Middle up → Jump (
↑) - No fingers up (fist) → Slide (
↓) - All fingers up → Idle (no action)
- Index finger up → Move Right (
Make sure you have Python installed. Then install the following libraries:
pip install opencv-python mediapipe pyautogui-
Clone this repository or download the code.
-
Run the script:
python hand_gesture_control.py
-
Show your hand in front of the webcam and start controlling your game!
| Gesture | Action | Key Pressed |
|---|---|---|
| ☝️ Index finger up | Move Right | → |
| ✌️ Index + Middle up | Move Left | ← |
| 👍 + ☝️ + ✌️ (Thumb + Index + Middle up) | Jump | ↑ |
| ✊ Fist (No fingers up) | Slide | ↓ |
| ✋ All fingers up | Idle | None |
- Works best in good lighting.
- Keep only one hand in the camera frame.
- Some games may require different key mappings (you can edit in the code).