Under the hood
How a webcam learns to see your hand
Air Ink runs on MediaPipe, Google's free toolkit of small AI vision models that run on your own device. Every camera picture goes through these steps, about 30 times a second. For the whole story, with the real code and a note beside each step, read the full notes.
01 · The pipeline
From pixels to a line on screen
Camera
The browser hands over one video frame: a grid of coloured pixels.
Palm detector
AI model 1 scans the whole frame and draws a box around each palm.
Hand landmarks
AI model 2 looks only inside the box and places 21 points.
Gesture classifier
AI model 3 reads the 21 points and names the shape.
Our rules
Smoothing, timers, and custom gestures like pinch and frame.
Canvas layers
Ink, fog and fire are painted on see-through sheets.
02 · Two models, not one
First find the palm, then the fingers
Fingers bend into endless shapes, so a whole hand is hard to spot. A palm is rigid and roughly square, which makes it far easier. Model 1 finds the palm, then model 2 studies just that small crop in detail.
Why it's fast: after the first frame, the palm detector mostly rests. The 21 points from the last frame predict where the hand will be next, so only model 2 runs. Model 1 wakes up again only when the hand is lost.
03 · The 21 dots
Every hand becomes 63 numbers
Each of the 21 points has an x, a y and a z. Dot 8, the tip of your index finger, is the pen. Hover a dot to see its name.
x and yPosition as a fraction of the picture, from 0 to 1. Our code multiplies them by the screen size.
zRough depth, measured from the wrist. More negative means closer to the camera.
MirroringA mirror swaps left and right, so we flip it: screen x = (1 − x) × width.
How it learnedGoogle trained it on tens of thousands of real hand photos where people marked the 21 points, plus computer-drawn hands. We don't train anything; Air Ink uses the finished model as it is.
04 · Dots → gestures
Who decides which gesture it is
Six shapes come ready-made from MediaPipe's gesture model. The rest are simple geometry rules written for Air Ink on top of the 21 dots. Measuring against the size of the palm makes every rule work whether your hand is near or far.
Completely new gestures later? MediaPipe can also retrain its gesture classifier on your own example photos, using a tool called Model Maker. That is only needed if a simple rule isn't reliable enough.
05 · Our own code
Making it feel steady
Smoothing
The dots shake a little in every frame (grey). A “One Euro” filter smooths hard when you move slowly and lightly when you move fast (red), so lines are steady without lagging.
Holding steady
While you change shape, the model wobbles for a split second (blue = lift, red = draw). The tool only switches once a shape has lasted 3 frames, so there are no stray marks.
Layers
Each effect lives on its own see-through canvas above the video. Erasing ink never touches the fog, and a snapshot simply stacks the layers together.
06 · The engine
All inside your browser tab
WebAssembly
The models run as fast, compiled code inside the browser. Nothing to install.
Your graphics chip
The heavy maths goes to the GPU through WebGL when it can, and falls back to the processor when it can't.
Downloaded once
About 21 MB the first time: a 12.9 MB engine and an 8 MB hand model, served from deebee.lol. The 3.6 MB face model loads only when you turn on Fog.
Nothing uploaded
Video and microphone sound stay on your computer. Pictures you save go to your own Downloads folder.
At 30 frames a second, each frame gets 33 milliseconds for everything. Turn on the camera to measure your own device.