Fitting face, pose and hands into a 16.7 ms frame
The models in our real-time category add up to under 15 MB. Landmarks, smoothing and tracking all have to fit inside one frame budget, and the skeleton shook until we changed a few things.
Start with the time budget. At 30 fps a frame is 33 ms; at 60 fps it is 16.7 ms, and video decode, canvas drawing and compositing all come out of that. Little is left for inference. That is why the real-time models are oddly small: 0.2 MiB for face detection, 5.5 MiB for pose, 7.5 MiB for hands. Each one has to finish every frame.
Crop a box first, then find the points
Nobody regresses 468 facial landmarks over a full 1080p frame. A 0.2 MiB BlazeFace-class detector finds the face box, and a 128×128 crop goes to Face Mesh for the 468 points. Pose follows the same shape: detector gives the body box, Pose regresses 33 joints; hands give 21. Background pixels never reach the regressor, so the compute lands where the target is.
| Subcategory | Representative model | Output | Measured size |
|---|---|---|---|
| Face detection | MediaPipe Face Detection | Face box + 6 keypoints | ~0.2 MiB |
| Face mesh | MediaPipe Face Mesh | 468 3D landmarks | ~3.6 MiB |
| Pose | MediaPipe Pose | 33 joints | ~5.5 MiB |
| Pose (Tasks API) | MediaPipe Pose Landmarker | 33 points + world coords | ~9.0 MiB |
| Hands | MediaPipe Hand Landmarker | 21 joints | ~7.5 MiB |
| Gestures | MediaPipe Gesture Recognizer | 21 points + gesture label | ~8.0 MiB |
| All in one | MediaPipe Holistic | Face + pose + both hands | ~13.0 MiB |
The skeleton keeps shaking
Landmark models run independently per frame, so the output wobbles. Users never see mAP, they see a shaking skeleton. Our order is: drop low-score points with a confidence threshold, damp the high-frequency wobble with an exponential moving average, then give each target a stable id through tracking. The smoothing toggle in the pose demo is the middle step.
ByteTrack handles the last one, matching this frame’s boxes to last frame’s tracks by IoU and re-attaching the same id after an occlusion. It runs no neural network at all, plain WebAssembly is enough. Counting, speed and dwell time all need trajectories before they mean anything.
Keep camera frames inside the tab
Camera frames are the last thing you want to upload. From capture to draw the frame stays in the tab: no upload, no recording, no server logs. Losing the network round trip is also what lets gesture interaction land under 50 ms. Past that, people say the gesture does not follow.
const landmarker = await HandLandmarker.createFromOptions(vision, {
baseOptions: { modelAssetPath: '/models/hand_landmarker.task' },
runningMode: 'VIDEO',
numHands: 2,
});
const loop = () => {
if (video.readyState >= 2) {
const result = landmarker.detectForVideo(video, performance.now());
draw(canvas, result);
}
requestAnimationFrame(loop);
};Things we adjusted
- 640×480 is plenty for landmarks; 1080p roughly doubles inference time
- Never await network or decoding inside the rAF callback, dropped frames pile up as latency
- Draw the overlay on canvas 2D instead of adding and removing DOM nodes every frame
- Phones throttle after a few minutes; lower the inference rate rather than the resolution
Open the face, pose or hand demo and allow the camera to see the overlay live. The tracking demo uses the same clip, so occlude the subject and watch whether the id comes back.