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.
- 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
- Python 3.7+
- Webcam
- Windows OS (uses Windows-specific mouse control)
- Clone this repository:
git clone https://github.com/techieworld2/GTA-San Andreas-Motion-Controller.git
cd GTA-San-Andreas-Motion-Controller- Install required packages:
pip install -r requirements.txt- Make sure your webcam is connected and working
- Run the application:
python main.py- Position yourself in front of the camera so both hands are visible
- Use gestures to control:
- Forward: Point hand upward
- Backward: Point hand downward
- Left: Spread fingers and tilt left
- Right: Spread fingers and tilt right
- Jump: Thumbs up gesture
- Move your left index finger to control camera/mouse movement
- Smooth tracking with movement buffering
- Press 'q' to quit the application
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
calculate_angle(): Computes angles between hand landmarksis_thumbs_up(): Detects thumbs up gesture for jump actionget_movement_gesture(): Determines movement direction from right handtrigger_action(): Maps gestures to keyboard inputsmove_mouse_raw(): Handles raw mouse movement via Windows API
You can adjust these parameters in the code:
max_move = 50: Maximum mouse movement speedavg_dx * 2.5: Mouse sensitivity multipliermin_detection_confidence=0.7: Hand detection confidence threshold
- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is for educational purposes. Make sure you comply with game terms of service when using automation tools.