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!
-
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)
- Python 3.8+
- Webcam
- The following Python packages:
pip install -r requirements.txt- Clone this repository:
git clone https://github.com/yourusername/gesture-controller.git
cd gesture-controller- Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Start either the face gesture or hand gesture controller:
For face controls:
python face_gesture_controller.pyFor hand controls:
python hand_gesture_controller.py-
Launch your game (Asphalt or any racing game that uses WASD controls)
-
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
-
Press 'q' to quit the controller
This controller is designed to work with:
- Asphalt (all versions)
- Any racing game using WASD/Space controls
- Other games with similar control schemes
- 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
You can modify the key mappings and gestures in the source code to adapt the controller for different games or preferences.
This project is free to use for personal and educational purposes.
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.