How a face morph works: eyes, landmarks and triangles
A face-morph timelapse looks like magic and is mostly geometry. This is what Grow-Up Reel does for every pair of photos, all inside your browser. The code is open source if you want to read along.
1. Find the face
A small neural network, the MediaPipe face detector, looks at each photo and returns a box around every face it finds, with rough positions for the eyes, nose, mouth and ears. It works on photos up to several metres from the camera, so faces in group shots are found too. When a photo has more than one face, the biggest is picked first and you can choose another.
2. Map the face
A second model, the MediaPipe face landmarker, looks at a square crop around the chosen face and places 478 points on it: the outline of the jaw and forehead, the eyebrows, the corners and rims of the eyes, the irises, the nose and the lips. These are positions, not identities: nothing here says whose face it is.
3. Line up the eyes
Every photo gets a similarity transform: a scale, a rotation and a shift, and nothing else, so faces are never squashed. It's the one transform that puts the two eye centres exactly on two fixed points in the frame. After it, every face in the reel has its eyes in the same place, level, the same distance apart. That alone gives the classic face timelapse, and it's what the Fade and Cut transitions show.
4. Build a mesh of triangles
For a morph, about a hundred of the landmarks are used (outline, brows, eyes, nose, lips, cheeks), plus two rings of points around the face that carry the hair and shoulders along, plus a fixed border far outside the frame. Those points are joined into triangles with a Delaunay triangulation, which avoids long thin slivers. The same triangles are used for both photos, so each triangle in one face has a partner in the other.
5. Move the points, blend the pictures
For each frame of the transition, every point moves a step from where it sits on the first face to where it sits on the second. Each triangle of each photo is stretched to its new position, and the two stretched pictures are crossfaded. At the start you see the first face; halfway, both faces have the same shape and are half and half; at the end the second face has fully arrived. Easing at both ends makes the movement feel natural.
6. Make the video
Frames are drawn with WebGL on your graphics chip, captions are added on top, and each frame goes to your browser's built-in video encoder (WebCodecs). The music is synthesised with the Web Audio API, encoded the same way, and both are packed into an MP4 file. No frame and no photo leaves the page.
Why do some morphs look odd?
When one face is turned much more than the other, or the mouth is wide open in one and closed in the other, triangles have to stretch a lot in a short time. Leaving out strongly turned faces fixes most of it, or choose Fade.