Hand Gesture Gaming

A computer-vision project that reads your hand and steers the game. Gestures mapped straight to the W, A, S, D keys, in real time.

Python OpenCV NumPy PyAutoGUI scikit-learn

Your hand becomes the controller

Gestures to keys

Hand position is translated into slope and distance, then mapped to W/A/S/D keypresses via PyAutoGUI.

Real computer vision

OpenCV captures the webcam feed, isolates your hand by colour, and tracks its contour frame by frame.

Tunable trackbars

On-screen HSV trackbars let you dial in lighting and skin tone so only your hand is detected.

Real games

Tested driving through Need for Speed, GTA 5, Blur, and Spiderman. The gesture mapping is yours to customise.

How it works — the six-step pipeline

1
Camera init

camera.py starts the webcam and hands frames to the pipeline.

2
HSV calibration

trackbars.py exposes hue / saturation / value sliders so only your hand stays visible against the background.

3
Frame processing

processing.py applies the tuned colour mask and finds the hand contour in each frame.

4
Contour detection

The largest contour is extracted and its extreme points are used to calculate slope and distance.

5
Gesture mapping

control.py turns slope and distance values into one of four gestures: up, left, down, or right.

6
Keyboard simulation

directkeys.py fires the matching W/A/S/D keypress into the active game window via ctypes.

Games you can play with gestures

Need for Speed

Racing

GTA 5

Open world

Blur

Racing

Spiderman

Action

Works with any game that uses W/A/S/D controls. Customise the mapping in control.py.

Running in under a minute

Install & run
# clone the repo
git clone https://github.com/karantrehan3/Hand-Gesture-Recognition-Based-Interactive-Gaming.git
cd Hand-Gesture-Recognition-Based-Interactive-Gaming/src

# install dependencies
pip install -r requirements.txt

# launch
python main.py
1
Tune the mask

Drag the on-screen HSV trackbars until only your hand is visible against the background.

2
Go live

Set the Start trackbar to 1 to begin gesture recognition and start driving.

3
Best environment

Use a plain white or black background in a well-lit room for cleanest contour detection.

4
Customise mappings

Tweak slope & distance thresholds in control.py to remap gestures to your liking.

Watch it in action