Skip to content

techieworld2/GTA-San-Andreas-Motion-Controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GTA San Andreas Motion Controller

A computer vision-based gesture control system for GTA San Andreas using hand tracking via MediaPipe. Control your character's movement and camera with hand gestures captured through your webcam.

Features

  • Dual Hand Control:
    • Right hand controls character movement (forward, backward, left, right)
    • Left hand controls camera/mouse movement
  • Gesture Recognition:
    • Thumbs up gesture triggers jump/special action
    • Hand position and spread angle determine movement direction
  • Smooth Controls: Buffered mouse movement for smooth camera control
  • Real-time Processing: Live hand tracking with visual feedback

Requirements

  • Python 3.7+
  • Webcam
  • Windows OS (uses Windows-specific mouse control)

Installation

  1. Clone this repository:
git clone https://github.com/techieworld2/GTA-San Andreas-Motion-Controller.git
cd GTA-San-Andreas-Motion-Controller
  1. Install required packages:
pip install -r requirements.txt

Usage

  1. Make sure your webcam is connected and working
  2. Run the application:
python main.py
  1. Position yourself in front of the camera so both hands are visible
  2. Use gestures to control:

Right Hand Controls (Movement):

  • Forward: Point hand upward
  • Backward: Point hand downward
  • Left: Spread fingers and tilt left
  • Right: Spread fingers and tilt right
  • Jump: Thumbs up gesture

Left Hand Controls (Camera):

  • Move your left index finger to control camera/mouse movement
  • Smooth tracking with movement buffering
  1. Press 'q' to quit the application

How It Works

The system uses MediaPipe for real-time hand landmark detection and implements:

  • Hand Tracking: Detects up to 2 hands simultaneously
  • Gesture Recognition: Analyzes hand pose and finger positions
  • Movement Mapping: Converts gestures to keyboard inputs (WASD)
  • Mouse Control: Maps left hand movement to raw mouse input
  • Smoothing: Uses deque buffer for stable camera control

Key Components

  • calculate_angle(): Computes angles between hand landmarks
  • is_thumbs_up(): Detects thumbs up gesture for jump action
  • get_movement_gesture(): Determines movement direction from right hand
  • trigger_action(): Maps gestures to keyboard inputs
  • move_mouse_raw(): Handles raw mouse movement via Windows API

Configuration

You can adjust these parameters in the code:

  • max_move = 50: Maximum mouse movement speed
  • avg_dx * 2.5: Mouse sensitivity multiplier
  • min_detection_confidence=0.7: Hand detection confidence threshold

Troubleshooting

  • No hand detection: Ensure good lighting and hand visibility
  • Jerky movement: Adjust the movement multiplier or buffer size
  • Wrong gestures: Check hand orientation and finger positions
  • Performance issues: Close other applications using the webcam

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Disclaimer

This project is for educational purposes. Make sure you comply with game terms of service when using automation tools.

Acknowledgments

  • MediaPipe for hand tracking capabilities
  • OpenCV for computer vision processing

About

Computer vision-based gesture control system for GTA San Andreas using hand tracking

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages