I taught my webcam to read hands. Hold up a letter in sign language and it spells it out on screen – first letters, then whole words. It also has a build-your-own-dataset mode, so you can teach it your own signs.

What it does
MediaPipe finds the landmarks of your hand – the joints of every finger – and a classifier turns those landmarks into letters, then letters into words on screen. In dataset mode, you hold a sign, press a key, and the translator records that hand shape under a letter of your choice, so you can build your own dataset and train your own model.
- MediaPipe hand landmarks become letters, then words
- Live mode reads your webcam in real time
- Dataset mode lets you build your own sign dataset
- Demo mode spells a word with no camera at all
What it spelled
The demo spells HELLO correctly, letter by letter, on screen. The demo centroid model scored 92.2% on 640 held-out synthetic samples, train.py –synthetic reached 93.9% (601/640), and the sample CSV scored 98.4% on 64 test samples.

| Test | Score |
|---|---|
| Demo spelled | HELLO, correct |
| Demo centroid model, 640 held-out synthetic samples | 92.2% |
| train.py –synthetic | 93.9% (601/640) |
| Sample CSV, 64 test samples | 98.4% |
Live mode needs a webcam plus MediaPipe and OpenCV. Demo mode needs only the standard library – it replays the sample landmarks, so you can watch the translator spell HELLO with nothing installed beyond Python itself.
How it works
MediaPipe watches the webcam and returns 21 landmarks for the hand – wrist, knuckles and fingertips. Those landmarks become a feature vector, a scikit-learn classifier turns it into a letter, and letters accumulate into a word on screen. OpenCV handles the camera, and training runs in Colab.

- OpenCV grabs a frame from the webcam
- MediaPipe finds the 21 hand landmarks
- The landmarks are normalised into a feature vector
- The classifier predicts a letter
- Letters build up into a word on screen
The maths
Each hand becomes 63 numbers: the x, y and z of 21 landmarks, measured relative to the wrist and scaled by the size of the hand, so the same sign gives nearly the same numbers wherever it is in the frame. The classifier is a nearest-centroid model: for every letter it keeps the average feature vector of that letter’s training samples, and a new hand is assigned to whichever letter’s average it is closest to.
Accuracy is simply the share of held-out samples the classifier got right – 601 out of 640 is 93.9%. The demo centroid model, a lighter version of the same idea, scored 92.2% on the same kind of held-out synthetic samples, and the sample CSV scored 98.4% on its 64 test samples because those samples are clean and consistent.
What you need
- Python 3.12
- MediaPipe
- OpenCV
- A webcam for live mode
Build it
Install the dependencies, collect a dataset if you want your own signs, train the model, and run the translator.
pip install -r requirements.txtpython src/collect.py --letter Apython src/train.py --syntheticpython src/main.py --demo --word HELLOpython src/main.py --liveThe code

sign-language-translator/
+-- src/main.py
+-- src/landmarks.py
+-- src/model.py
+-- src/train.py
+-- src/collect.py
+-- data/sample_landmarks.csvlandmarks.py turns MediaPipe’s 21 hand points into a feature vector:
import numpy as np
def landmarks_to_features(landmarks):
points = np.array([[p.x, p.y, p.z] for p in landmarks])
wrist = points[0].copy()
points = points - wrist
scale = np.max(np.abs(points))
if scale > 0:
points = points / scale
return points.flatten()
def extract_features(hand_landmarks):
return landmarks_to_features(hand_landmarks.landmark)model.py is the nearest-centroid classifier – one average hand shape per letter:
import numpy as np
class CentroidModel:
def fit(self, X, y):
self.labels = sorted(set(y))
self.centroids = {}
for label in self.labels:
rows = [x for x, target in zip(X, y) if target == label]
self.centroids[label] = np.mean(rows, axis=0)
return self
def predict(self, features):
best_label = None
best_distance = None
for label, centroid in self.centroids.items():
distance = float(np.linalg.norm(features - centroid))
if best_distance is None or distance < best_distance:
best_label = label
best_distance = distance
return best_labelWhat broke
Live landmarks jitter – the hand wobbles a few pixels every frame, so the predicted letter flickered between two or three neighbours. The fix was smoothing, and holding a letter for several frames before accepting it: a letter only counts once it has been the prediction for a run of frames, so a one-frame wobble can no longer change the word.
Download the project
Unzip the project, pip install the requirements, then run main.py –demo to watch it spell HELLO with no camera at all.
Premium Download
Get the complete project code
