This project demonstrates a real-time skeleton-based gesture recognition system using MediaPipe and TensorFlow, with deployment targeted for Raspberry Pi.
We use hand joint point detection to extract 3D keypoints (x, y, z) from both hands, and train a neural network model to classify custom gestures.
- Build a lightweight gesture recognition pipeline.
- Train on gesture keypoints extracted via MediaPipe.
- Deploy and run inference on low-resource devices like Raspberry Pi.
Tested on:
Python 3.8.11,TensorFlow 2.3.0
conda create -n gesture python=3.8.11
conda activate gesture
pip install tensorflow==2.3.0
pip install tensorflow-gpu==2.3.0 # Optional for CUDA support
pip install opencv-python
pip install mediapipe
pip install scikit-learn
pip install matplotlib| File / Script | Description |
|---|---|
draw_keypoints.py |
Draws 2D keypoints and connects joints on images. |
get_keypoints.py |
Extracts 21 hand joints per hand (x, y, z), handles zero-padding when missing. |
mediapipe_tool.py |
Performs joint prediction using MediaPipe. |
keypointDemo.py |
Demo: Shows if joint points are detected correctly (see image below). |
keypoint_label.py |
For collecting custom gesture keypoint datasets. |
gesture.ipynb |
Notebook for training gesture recognition model (e.g., on Google Colab). |
gesture_recognition.py |
Real-time gesture recognition with webcam or video input. |
python keypointDemo.pyUse this script to label and store custom gestures:
python keypoint_label.pyEach sample is saved with keypoints from both hands, padded if necessary.
The neural network is trained using gesture.ipynb, where joint keypoint arrays are fed into a simple classifier.
You can run the notebook on Google Colab for GPU acceleration.
Run gesture recognition in real time:
python gesture_recognition.py- Make sure
MediaPipehas access to your webcam or input image source. - Joint detection accuracy may drop under poor lighting or occlusion.
- Extend the dataset with more gesture samples for better model generalization.
- Google MediaPipe
- TensorFlow team

