Skip to content

pragya-manna/Open-CV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ‹ Gesture Controlled Game using MediaPipe and OpenCV

A Python-based hand gesture recognition app that allows you to control your system (keyboard presses) using simple finger gestures via webcam. It uses MediaPipe for real-time hand tracking and PyAutoGUI for simulating keypresses.


πŸ“½οΈ Demo

  • Move hand right β†’ Right Arrow
  • Move hand left β†’ Left Arrow
  • Move hand up β†’ Up Arrow
  • Move hand down β†’ Down Arrow

These gestures simulate keyboard arrow keys in any active application (like car racing games, character movement, or presentations).


πŸ› οΈ Requirements

Install dependencies with:

pip install opencv-python mediapipe pyautogui

Python 3.8+ is recommended.


πŸ“ Project Files

  • gesture_control.py – Main script that runs the gesture control
  • No other files required; runs directly using webcam (Used DroidCam app for camera)

πŸš€ How to Run

  1. Connect your webcam.
  2. Run the script:
python gesture_control.py
  1. Hold your hand in the center for auto-calibration.
  2. Move hand up/down/left/right to control.
  3. Press c to recalibrate anytime.
  4. Press q to quit.

🧠 How It Works

  • Detects hand landmarks using MediaPipe Hands.
  • Takes the wrist point (landmark 0) as the reference.
  • Calibrates a neutral center position.
  • Calculates hand displacement (dx, dy) from center:
    • If movement crosses a dead zone threshold β†’ triggers a direction.
  • Ensures gestures don’t repeat too fast using a small delay.
  • Sends corresponding arrow key presses with PyAutoGUI.

βš™οΈ Key Features

  • Calibration System β†’ Press c to reset neutral position.
  • Dead Zone β†’ Ignores small jittery movements.
  • Gesture Delay β†’ Prevents multiple keypress spam.
  • Works in real time with ~30fps.

πŸ’‘ Gesture Mappings

Hand Movement Keys Triggered
Move Right β†’ Right Arrow
Move Left ← Left Arrow
Mode Up ↑ Up Arrow
Mode Down ↓ Down Arrow

πŸ”’ Notes & Tips

  • Good lighting = better tracking.
  • Keep only one hand visible.
  • Works on Windows, macOS, Linux.
  • Can be easily extended (e.g., WASD keys, custom actions).

πŸ§‘β€πŸ’» Author

Built with ❀️ by Pragya using Python, MediaPipe, OpenCV, PyAutoGUI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages