Skip to content

Allen203060/ghostHand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘ป GHOSTHAND

Control any game with your bare hands. No hardware. No controller. Just you.

Python MediaPipe OpenCV License Status Hackathon


๐ŸŽฌ Demo

[๐Ÿ“น Demo GIF / Video Placeholder] Hold both hands up in front of your webcam like gripping a steering wheel. Tilt to steer. Push apart to throttle. Bring together to brake.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         [ WEBCAM FEED PLACEHOLDER ]         โ”‚
โ”‚                                             โ”‚
โ”‚   Left Hand โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ— Right Hand  โ”‚
โ”‚              โ†• Tilt = Steer                 โ”‚
โ”‚         โ†” Distance = Gas / Brake            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โšก What Is GHOSTHAND?

GHOSTHAND is an open-source, AI-powered gesture controller that turns your webcam into a full game input device โ€” no physical controller required.

Using MediaPipe's 21-point hand landmark tracking averaged across both hands, GHOSTHAND computes a stable, noise-resistant hand center and maps real-world hand movements directly to virtual gamepad inputs via a software Xbox 360 controller.

Currently supports racing games as the first game profile, with FPS, shooter, and custom profiles in active development.


๐Ÿง  How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              โ”‚     โ”‚                     โ”‚     โ”‚                      โ”‚
โ”‚   WEBCAM     โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  MediaPipe Hands    โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  GHOSTHAND Engine    โ”‚
โ”‚  (30fps)     โ”‚     โ”‚  21 Landmarks/Hand  โ”‚     โ”‚                      โ”‚
โ”‚              โ”‚     โ”‚                     โ”‚     โ”‚  โ€ข Average 21 pts    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  โ€ข Compute angle     โ”‚
                                                 โ”‚  โ€ข Compute distance  โ”‚
                                                 โ”‚  โ€ข Apply deadzone    โ”‚
                                                 โ”‚  โ€ข Smooth output     โ”‚
                                                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                            โ”‚
                                                            โ–ผ
                                                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                                 โ”‚   vgamepad (Xbox360) โ”‚
                                                 โ”‚                      โ”‚
                                                 โ”‚  Left Stick  โ†’ Steer โ”‚
                                                 โ”‚  R Trigger   โ†’ Gas   โ”‚
                                                 โ”‚  L Trigger   โ†’ Brake โ”‚
                                                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Gesture Mapping (Racing Profile)

Gesture Input Game Action
Tilt hands left/right (like a wheel) Left Joystick X Steering
Hands push apart (wider) Right Trigger Throttle / Gas
Hands pull together (closer) Left Trigger Brake
Calibration pose (flat, neutral) Reference frame Zero point

The 21-Landmark Averaging

Instead of tracking just the wrist (a single noisy point), GHOSTHAND averages all 21 MediaPipe hand landmarks to compute a stable hand center:

def get_hand_center(landmarks, w, h):
    xs = [lm.x * w for lm in landmarks.landmark]  # all 21 x coords
    ys = [lm.y * h for lm in landmarks.landmark]  # all 21 y coords
    return int(np.mean(xs)), int(np.mean(ys))       # averaged center

This means any one jittery point only contributes 1/21 to the result โ€” giving rock-solid tracking even with partial occlusion or fast movement.


๐Ÿš€ Getting Started

Prerequisites

  • Python 3.9+
  • A webcam
  • Windows OS (vgamepad requires Windows for virtual Xbox controller)
  • A game that supports Xbox 360 controller input

Installation

# 1. Clone the repo
git clone https://github.com/yourusername/GHOSTHAND.git
cd GHOSTHAND

# 2. Create a virtual environment (recommended)
python -m venv venv
venv\Scripts\activate       # Windows
# source venv/bin/activate  # Mac/Linux

# 3. Install dependencies
pip install -r requirements.txt

requirements.txt

opencv-python>=4.8.0
mediapipe>=0.10.0
vgamepad>=0.1.0
numpy>=1.24.0

โš ๏ธ vgamepad requires ViGEmBus Driver on Windows. Download and install from: https://github.com/nefarius/ViGEmBus/releases

Running GHOSTHAND

python GHOSTHAND.py

Controls

Key Action
C Start 5-second calibration countdown
Q Quit GHOSTHAND

Calibration Steps

1. Launch GHOSTHAND
2. Hold both hands up in front of the camera
3. Position them like gripping a flat, level steering wheel
4. Press C โ€” you have 5 seconds to hold the pose
5. The line between your hands turns GREEN = you're calibrated
6. Drive!

โš™๏ธ Configuration

All tuning parameters are at the top of GHOSTHAND.py:

STEERING_SENSITIVITY = 1.0   # Multiplier on steering output
MAX_ANGLE_LOCK       = 50    # Degrees of tilt for full lock
SMOOTHING_FACTOR     = 0.5   # 0 = instant, 1 = never moves
DEADZONE_STEER       = 1500  # Joystick units ignored near center
DIST_RANGE           = 120   # Pixel range for full throttle/brake
DEADZONE_DIST        = 40    # Pixel deadzone for gas/brake
STEER_INVERT         = 1     # Set to -1 to flip steering direction

๐ŸŽฎ Tested Games

Game Profile Status
Forza Horizon 5 Racing โœ… Working
BeamNG.drive Racing โœ… Working
Need for Speed Heat Racing โœ… Working
Rocket League Racing/Sports ๐Ÿงช Experimental

๐Ÿ”ฎ Roadmap & Future Implementations

GHOSTHAND is just getting started. Here's what's coming:

๐ŸŽฏ v2.0 โ€” Multi-Game Profile System

A full profile switcher letting you load different gesture โ†’ input mappings per game genre.

GHOSTHAND/
  profiles/
    racing.json       โ† current
    fps.json          โ† coming soon
    shooter.json      โ† coming soon
    fighting.json     โ† planned

๐Ÿ”ซ v2.1 โ€” FPS / Shooter Profile

Map hand gestures to mouse + keyboard inputs for first person games:

  • Aim โ€” track dominant hand position to move crosshair
  • Shoot โ€” pinch gesture (index + thumb) = left click / fire
  • ADS (aim down sights) โ€” bring hands close together
  • Reload โ€” specific fist + open gesture combo
  • Movement โ€” off-hand tilt controls WASD equivalent

๐Ÿ–ฅ๏ธ v3.0 โ€” Dedicated Desktop App (GUI)

Replace the raw script with a proper application:

  • Game profile selector with live preview
  • Sensitivity sliders with real-time feedback
  • Auto-detection of running games
  • Save / load custom profiles
  • Built with PyQt6 or Electron

๐Ÿค– v3.5 โ€” Gesture ML Model

Train a custom classification model (TFLite / ONNX) on top of MediaPipe landmarks to recognize complex gestures:

  • Fist = handbrake
  • Peace sign = horn / special action
  • Open palm = pause / menu
  • Thumbs up = confirm

๐ŸŒ v4.0 โ€” Cross-Platform & Browser Support

  • Linux / Mac support via alternative virtual controller drivers
  • WebSocket bridge for browser-based games
  • Mobile companion app (phone as secondary controller)

๐Ÿ•น๏ธ v4.5 โ€” Full Game Compatibility Matrix

Official profiles and testing for:

Genre Target Games
Racing Forza, NFS, Gran Turismo
FPS CS2, Valorant, Apex Legends
Third-Person Shooter GTA V, The Division
Fighting Mortal Kombat, Street Fighter
Sports FIFA, Rocket League
Battle Royale PUBG, Fortnite

๐Ÿ—๏ธ Project Structure

GHOSTHAND/
โ”œโ”€โ”€ GHOSTHAND.py          โ† Main script (current prototype)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ profiles/             โ† (coming v2.0)
    โ”œโ”€โ”€ racing.json
    โ””โ”€โ”€ fps.json

๐Ÿค Contributing

GHOSTHAND is built for the open source community. Contributions are welcome.

# Fork โ†’ Clone โ†’ Branch โ†’ PR
git checkout -b feature/fps-profile
git commit -m "feat: add FPS shooter gesture profile"
git push origin feature/fps-profile

Areas we especially need help with:

  • Testing with more games and reporting results
  • Building out new game profiles
  • Improving gesture recognition accuracy
  • Cross-platform support (Linux / Mac)
  • UI/UX for the desktop app (v3.0)

๐Ÿ“„ License

MIT License โ€” free to use, modify, and distribute.


๐Ÿ’€ Built with

  • MediaPipe โ€” Hand landmark detection
  • OpenCV โ€” Camera capture & visualization
  • vgamepad โ€” Virtual Xbox 360 controller
  • NumPy โ€” Landmark averaging math

GHOSTHAND โ€” because the best controller is the one you can't see.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages