Skip to content

MayureshNaik111/Traffic-Rider-Gesture-Control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Traffic Rider Gesture Control

Control the game "Traffic Rider" using real-time hand gestures detected via your webcam. No keyboard input required!

Features

  • Gesture Control: Control throttle, brake, and lean left/right using hand gestures
  • Real-time Detection: Uses MediaPipe Tasks API for fast and accurate hand tracking
  • Overlay Display: Shows gesture information and countdowns on top of the game
  • Safe Exit: Requires holding both palms open for 2 seconds to quit

Requirements

  • Python 3.8+
  • Webcam
  • opencv-python
  • mediapipe
  • pynput

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Traffic-Rider-Gesture-Control
  2. Install dependencies

    pip install opencv-python mediapipe pynput
  3. Download model file Download hand_landmarker.task and place it in the same directory as the script: https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task

Usage

  1. Start the application

    python traffic_rider_gesture_control.py
  2. Gesture controls The script will display the available gestures on startup:

      Right Fist        →  Up Arrow    (Accelerate)
      Right Open Palm   →  Down Arrow  (Brake)
      Left Hand Tilt L  →  Left Arrow  (Lean Left)
      Left Hand Tilt R  →  Right Arrow (Lean Right)
      Both Open Palms   →  QUIT        (Hold 2s)
    
  3. Play the game Switch to Traffic Rider and play! The gesture controls work in the background via pynput, so the game window can stay focused.

Gesture Controls

Gesture Key Description
Right Fist Up Arrow Accelerate
Right Open Palm Down Arrow Brake
Left Hand Tilt Left Left Arrow Lean Left
Left Hand Tilt Right Right Arrow Lean Right
Both Open Palms Quit Hold for 2 seconds to exit

Tuning

If the gestures aren't working as expected, adjust these constants in the script:

  • TILT_LEFT_THRESHOLD: Lower = left tilt triggers more easily

  • TILT_RIGHT_THRESHOLD: Increase if right tilt triggers too easily

  • FIST_CURL_THRESHOLD: Increase if fist/brake detection is too sensitive

Troubleshooting

  • Camera not detected: Make sure your webcam is connected and not being used by another application
  • Gestures not working: Ensure your hands are clearly visible to the webcam and well-lit
  • Performance issues: Try reducing CAMERA_WIDTH and CAMERA_HEIGHT, or increasing PROCESS_EVERY_N_FRAME to skip more frames
  • Model file missing: Download hand_landmarker.task manually from the URL above and place it in the same directory as the script.

About

Control Traffic Rider using real-time hand gestures via webcam — powered by OpenCV & MediaPipe

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages