Go to Map Courses Lab Glossary How it works Troubleshooting Start →
ITEN
← Course 02 · Seeing (Lesson 02.05 · 22 minutes · Camera · First model)

Hands, body, face.

A ready-made model turns your hand into 21 points. From there you teach the phone the gestures you want with a few examples, and with a bit of geometry you measure angles without training anything.

What you learn
  1. How a model finds the points of the hands, the body and the face
  2. Why a model that learns from points is small and fast
  3. What it means to normalize the points before you use them
  4. When a rule on the points is enough instead of a model
You need to know

If you don't remember one of these, the link takes you to the chapter that explains it.

How do you want to follow it
Preparing the scene…
  1. 01 The hand

    A hand becomes 21 points.

    Open your hand in front of the camera. A ready-made model from Google, MediaPipe, finds 21 key points01.04. The wrist, then four points for each finger, from the base to the tip. For each point it gives three numbers, the position in the photo and an estimate of how close it is. That's 63 numbers in all, instead of millions of pixels.

    In practice. The 21 points always come in the same order. Number 4 is the tip of the thumb, number 8 the tip of the index finger. With just these two you can already spot the pinch gesture.

01 / 07
(Go deeper)

A few more numbers.


(01)

MediaPipe, Google's ready-made models

MediaPipe collects models already trained for hands, body, face, objects and more, ready for Android, iOS and the browser. The hand model is a single file of about 8 MB that holds two models, the one for the palm and the one for the points. It runs in real time even on mid-range phones.

To train it, Google marked the 21 points by hand on about 30,000 real photos. Then it added hands drawn by computer in many poses and kinds of light, because there the exact position of each point is already known and nobody has to mark it.

  • 21points on the hand
  • 33points on the body
  • 478points on the face
(02)

Why 63 numbers beat 150,000 pixels

A model that classifies gestures from pixels has to learn from scratch what a hand is, and for that it needs thousands of photos. One that starts from the points gets that work already done. Two different gestures are far apart in the 63 numbers even when the photos look alike, and 20 or 30 examples per gesture are enough.

There's a privacy advantage too. In the gesture dataset you can save only the points, without faces, rooms or people in the background. For the body, and above all for the face, the points are still personal data, though, and you have to treat them that way.

(03)

Normalization in code

If you program, it takes a few lines. You subtract the wrist from every point, find the point farthest from the wrist and divide everything by that distance. The result is 63 numbers between minus one and one, ready for the gesture model.

You have to save the same numbers in the dataset and use them live. If you normalize the examples one way and the new frames another way, the model sees two different worlds and makes mistakes for no clear reason.

const wrist = points[0];
const shifted = points.map(p => [p.x - wrist.x, p.y - wrist.y, p.z - wrist.z]);
const scale = Math.max(...shifted.map(([x, y]) => Math.hypot(x, y)));
const numbers = shifted.flat().map(v => v / scale);   // 63 numbers
(Try it on your phone)

Three gestures of your own


In the lab you teach the phone three gestures you choose, starting from the 21 points of the hand. You need ten minutes and a room with normal light.

  1. Open the lab with the button below. It already starts with the Hand input.
  2. Create three classes, for example thumbs up, fist and open hand, plus a nothing class for when your hand isn't making any of the three gestures.
  3. For each gesture record 20 examples, with both hands and at different distances.
  4. Press Train. With points it only takes a few seconds.
  5. In Use, try the gestures against the light and with one hand half hidden, and watch the confidence.
Open the lab →
(Quiz)

4 questions to close the lesson.

When you have answered them all, the lesson counts as done and its stone on the map turns yellow. Answering is what counts, not the score.


  1. (01)

    How many numbers reach your gesture model for each frame?

  2. (02)

    Your model recognizes the fist only when the hand is in the top left. What's missing?

  3. (03)

    You want to count squats. What's the simplest way?

  4. (04)

    Half of the hand is hidden behind a mug. What does the points model do?

(Next lesson · 03.01) Sound becomes an image