/GestureControl-HillClimbRacing

GestureControl-HillClimbRacing: Python script using OpenCV & MediaPipe for hand gesture recognition, enabling intuitive control of Hill Climb Racing game. Translate hand movements into in-game commands for an interactive gaming experience.

Primary LanguagePython

Hill Climb Racing Hand Gesture Control

This Python script utilizes the OpenCV and MediaPipe libraries to control the Hill Climb Racing game using hand gestures. The program captures the video feed from the default camera, tracks hand movements, and interprets specific gestures to generate commands for controlling the game.

Requirements

  • Python
  • OpenCV
  • MediaPipe
  • PyAutoGUI

Code Overview

The script consists of the following key components:

  1. Import necessary libraries:
    • cv2 (OpenCV)
    • mediapipe
    • pyautogui
    • time
  2. Initialize video capture from the default camera.
  3. Create instances for hand tracking using MediaPipe and initialize drawing utilities.
  4. Define functions for finding commands based on hand landmarks and for tracing hand movements.
  5. Inside the main loop:
    • Read frames from the camera.
    • Flip the frame horizontally for better user experience.
    • Process the frame to detect hand landmarks and draw connections.
    • Identify commands based on hand gestures.
    • Control the Hill Climb Racing game using PyAutoGUI based on detected commands.
    • Show the processed frame with hand landmarks on a window.
    • Exit the loop if the 'q' key is pressed.

Hand Gesture Commands

  • Command 1: Move the vehicle by pressing gas.
  • Command 2: Stop the vehicle by applyinig brakes.
  • No Command: No vehicle movement.

Usage

Ensure that the required libraries are installed before running the script. The program captures your hand gestures through the camera and translates them into commands for controlling the Hill Climb Racing game.

Important Notes

  • This script assumes that the Hill Climb Racing game is running and active.
  • Adjustments may be needed for optimal hand gesture detection based on environmental conditions and camera placement.
  • Exit the program by pressing the 'q' key in the output window.

Author

Author: Livisha K