A real-time hand gesture recognition system designed to control video game characters using computer vision and deep learning. This project is part of the course Artificial Intelligence for Interactive Media - TNM114.
This system uses trained convolutional neural networks to identify hand gestures from a webcam feed. The recognized gestures are sent to a Godot game engine to control a swarm of characters in real-time, creating an intuitive gesture-based game controller.
The project combines:
- Python Backend - OpenCV and TensorFlow for real-time gesture recognition
- Godot Frontend - Game engine that listens for gesture inputs via WebSocket and controls character swarms accordingly
- Real-time hand detection using MediaPipe
- CNN-based gesture classification trained on the HagRID dataset
- Two approaches:
- Landmark-based: Uses hand skeleton coordinates for fast inference
- Image-based: Uses 64×64 hand region images for higher accuracy
- WebSocket communication to send recognized gestures to Godot
- Listens for gesture inputs from Python via WebSocket
- Interprets gestures as game commands
- Controls character swarm behavior based on recognized gestures
The project uses the HagRID (Hand Gesture Recognition Image Dataset) for training. The dataset is preprocessed and organized into labeled gesture classes stored in:
c:\Project\TNM114\HagridCNN\hagrid_data\processed_images
- hand_gesture_landmarks.keras - Landmark-based model (fast, real-time)
- hand_gesture_cnn.keras - CNN image-based model (higher accuracy)
python model_trainer.pyTwo demo scripts illustrate the different recognition approaches:
python speaker_demo.py # Landmark-based approach with visual feedback
python speaker_cnn.py # CNN image-based approach with higher accuracyBoth demos display real-time gesture recognition from your webcam and show the predicted gesture with confidence score.
To use the full gesture-controlled game:
- Launch the Godot game engine and run the game project
- In a separate terminal, run the Python gesture recognition script:
python speaker.py # Connects to the Godot game via WebSocketThe Python script will connect to the Godot game via WebSocket, sending recognized hand gestures in real-time. These gestures control the swarm of characters in the game, allowing you to steer them intuitively using hand movements captured from your webcam.
- Python 3.8+
- TensorFlow/Keras
- OpenCV
- MediaPipe
- NumPy
- Godot Engine 4.x (for game integration)