Skip to content

BillyMRX1/gesture-controller

Repository files navigation

Gesture Game Controller

A hands-free way to play racing games like Asphalt using face or hand gestures through your webcam. Control your car using natural movements without touching your keyboard!

Features

  • Face Gesture Controller: Control using eye blinks

    • Close both eyes: Brake/Reverse (Space)
    • Close left eye: Turn left + Nitro (A + S)
    • Close right eye: Turn right + Nitro (D + S)
    • Keep eyes open: Accelerate (W)
  • Hand Gesture Controller: Control using hand positions

    • Closed fist: Brake/Reverse (Space)
    • Index finger only: Turn right + Nitro (W + S + D)
    • Middle finger only: Turn left + Nitro (W + S + A)
    • Index + Middle fingers: Accelerate (W)
    • Open hand (all fingers): Nitro (S)

Requirements

  • Python 3.8+
  • Webcam
  • The following Python packages:
pip install -r requirements.txt

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/gesture-controller.git
cd gesture-controller
  1. Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

  1. Start either the face gesture or hand gesture controller:

For face controls:

python face_gesture_controller.py

For hand controls:

python hand_gesture_controller.py
  1. Launch your game (Asphalt or any racing game that uses WASD controls)

  2. Position yourself in front of the webcam:

    • For face controls: Ensure your face is clearly visible
    • For hand controls: Hold your hand up with palm facing the camera
  3. Press 'q' to quit the controller

Game Compatibility

This controller is designed to work with:

  • Asphalt (all versions)
  • Any racing game using WASD/Space controls
  • Other games with similar control schemes

Tips

  • Ensure good lighting for better gesture detection
  • Keep a consistent distance from the camera
  • For face controls, maintain a neutral head position
  • For hand controls, keep your hand within the camera frame

Customization

You can modify the key mappings and gestures in the source code to adapt the controller for different games or preferences.

License

This project is free to use for personal and educational purposes.

Third-party Libraries

This project uses the following open-source libraries:

  • OpenCV (cv2) - Apache 2.0 License
  • MediaPipe - Apache 2.0 License
  • pynput - LGPL v3.0 License

Please respect the licenses of these third-party libraries when using or distributing this code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages