What a camera can sense
4 minYour webcam sends colour, frame after frame, and knows nothing about faces. A tracking model finds the face and hands back points. You'll draw a pair of glasses that follow those points.
Lesson video
Tastebud · 4:15 · Captions on screen
A camera sends only coloured pixels; a tracking model turns them into points your visual can follow.
- Why. The camera has no idea what a face is. A model finds the face in each frame and hands back numbered points, and your visual follows them.
- Real example. Lenskart's 3D Try On takes a picture from your phone's camera and puts the frames you choose on your face, so you can try glasses at home. (Lenskart, Nov 2026)
- When to break it. If the piece only needs to know that someone moved, compare each frame's pixels with the last one. No model, no points, and far less work for the phone.
- Common mistake. Drawing tracker points as if they were pixels. x and y arrive as fractions from 0 to 1, so unscaled drawings pile up in the top left corner.
Our take. Draw from the tracker's points, never from fixed spots on the screen. A filter placed at the centre fits only the person standing at the centre, and in a real room almost nobody does.
Each tracker hands back a different set of points
Pick the tracker by the body part your idea needs. A face gives 478 points and 52 expression scores, a hand gives 21 points and whether it's left or right, and a whole body gives 33.
Three trackers, three sets of points to build on
- Face: 478 points. Plus 52 expression scores, such as jawOpen and eyeBlinkRight. Try-ons and face filters start here, like Lenskart's 3D Try On.
- Hand: 21 points each. From the wrist to each fingertip, labelled left or right as the person's own hands. Good for pointing, pinching and drawing in the air.
- Body: 33 points. Shoulders, elbows, hips, knees and more. Google's Move Mirror (2018) matched your pose to more than 80,000 photos using PoseNet, a pose model on TensorFlow.js.
Points arrive as fractions, so scale them first
A tracker gives x and y from 0 to 1 across the frame, so the numbers work at any camera size. Multiply x by your canvas width and y by its height, then draw. Skip this and everything lands in one corner.
- Tracker says the nose is at x 0.62
- Drawn at 0.62 px from the left edge
- Every point piles up in the top left corner
- The filter seems to ignore the face
- Same point, x 0.62
- 0.62 × 320 px wide = 198 px
- The dot lands on the nose
- Resize the canvas and it still lands there
Numbers worked for this lesson on a 320 px canvas.
The camera needs a yes and a plain reason
The browser asks before any page can use the camera, and only over HTTPS. MediaPipe runs on the device, so frames can stay on the phone. Say that on the start screen, and ask again before saving any picture.
Consent comes before the first frame reaches the tracker
- Your page to Person: Start screen: we use your camera to place glasses; nothing leaves your phone. Say what the camera is for before the prompt appears, in one line.
- Your page to Browser: getUserMedia asks for the camera. This works only on an HTTPS page.
- Browser to Person: Allow this site to use your camera. The browser's own prompt. The page can't skip it or fake it.
- Person to Browser: Allow. If the person says no, show the experience with a sample photo instead of a dead screen.
- Browser to Your page: Live video, frame by frame. The tracker reads each frame on the device. Saving or sending a picture needs a second, separate yes.
Try it
Draw a pair of frames that follow a face
This is a simulation: the sandbox can't open your webcam, so a locked script plays made-up face points that move like a real head. Draw a circle round each eye and a bridge between them, so the frames ride along as the head moves, tilts and comes closer.
Tab adds two spaces. Press Esc, then Tab, to leave the editor.
- Both eyes come from the tracker's points (not yet)
- A circle sits on each eye (not yet)
- A bridge joins the two circles (not yet)
- The circles grow with the gap between the eyes (not yet)
What to notice: Watch the frames when the head drifts to the edge and tilts. Because every line is drawn from the tracker's points, the glasses stay on the eyes wherever the person stands. Size them from Math.hypot of the eye gap and they also grow as the face comes closer.
Quick check
You're prototyping a made-up Nykaa lipstick try-on for a store mirror, and the shade should change each time the person blinks. Which output do you read?
Watch next
Watch it for The Face Landmarker turning a webcam picture into a mesh of points in the browser, and which settings decide how many faces it looks for.
Watch it for Hand keypoints drawn as dots, then a painting sketch that follows one fingertip, the same points-to-visual step you take here.
Connects to: 4.2 Shapes, colour and input · 2.3 JavaScript for interaction · 8.2 Face and world effects for social · 11.4 Voice, vision and multimodal input
Sources · checked Nov 2026
- Google AI Edge: MediaPipe Face Landmarker guideDetects face landmarks and expressions in images, video and a live feed; 478 3D landmarks; 52 blendshape scores; a bundle of a face detector (BlazeFace), a face landmark model and a blendshape model; x and y normalised to 0.0 to 1.0 by image width and height
- Google AI Edge: Face Landmarker for webInstall @mediapipe/tasks-vision; on the web a live camera uses runningMode VIDEO with requestAnimationFrame and detectForVideo on each frame
- Google AI Edge: MediaPipe Hand Landmarker guide21 3D keypoints per hand; a Left or Right label for each hand, as the person's own hands; a palm detector and a hand landmark model
- Google AI Edge: MediaPipe Pose Landmarker guideTracks 33 body landmark locations, in image coordinates and in 3D world coordinates
- Google AI Edge: MediaPipe Solutions guideRuns models directly in your app, including live camera streams, with on-device execution, on web, Android, iOS and Python
- GitHub: google-ai-edge/mediapipeMediaPipe is open source under the Apache 2.0 licence
- npm: @mediapipe/tasks-visionLatest version 1.2.3, published 11 Nov 2026
- Lenskart: Eyewear on the App Store (India)3D Try On: try eyeglasses and sunglasses at home, virtually, using an image from your mobile camera; Face Analysis suggests a frame size from a selfie
- Experiments with Google: Move MirrorJuly 2018, Google Creative Lab with PAIR and Research; you move in front of your webcam and it pulls up photos of matching poses in real time from more than 80,000 pictures; built with TensorFlow.js and PoseNet; no longer active
- MDN: MediaDevices.getUserMedia()Prompts the user for permission to use a camera; available only in secure contexts (HTTPS); fails if the person or a Permissions Policy denies access