"Compare the left half of the face with the right half" sounds like a five-line function. Then you try it on real selfies and discover that most of what you're measuring is the angle of the phone.
We built a browser-based face symmetry test on MediaPipe Face Landmarker. The photo and the landmarks stay on the device; only the resulting numbers ever leave it. This post walks through how the symmetry number is computed from landmarks, what we do about head pose, and where the approach stops working.
Step 1: pick mirror pairs, not all 478 points
Face Landmarker returns 478 points, but you don't need most of them for symmetry. You need points that have an obvious twin on the other side. We use twelve pairs, each a left and right index into the landmark array:
// L = image-left side, R = image-right side L: { eyeOuter: 33, eyeInner: 133, eyeTop: 159, eyeBottom: 145, browInner: 107, browPeak: 105, browOuter: 70, noseAla: 129, mouthCorner: 61, cheekbone: 234, temple: 127, jaw: 172 }, R: { eyeOuter: 263, eyeInner: 362, eyeTop: 386, eyeBottom: 374, browInner: 336, browPeak: 334, browOuter: 300, noseAla: 358, mouthCorner: 291, cheekbone: 454, temple: 356, jaw: 397 }, Plus seven points that should sit on the midline: top of forehead (as high as the landmarks reach, which isn't the hairline), nose bridge, nose tip, nose base, top of the upper lip, bottom of the lower lip, and chin.
Eleven of the pairs (all but the temples) are grouped into five areas so the result can say where the difference is: eyes (outer corner, inner corner, top, bottom), eyebrows (inner end, peak, outer end), nose (the nostril wings), mouth (the corners), and jaw (cheekbone and jaw angle). All twelve pairs are used to build the coordinate frame below.
Step 2: build a coordinate frame from the face itself
The naive approach measures in image coordinates: is the left eye at the same y as the right eye? That fails the moment someone tilts their head, because a 10° roll moves one eye up and the other down and you'd call it asymmetry.
The landmarks come with a z value, so instead we build a frame anchored to the face. First, convert the normalized coordinates to pixels (otherwise a non-square photo distorts every ratio), scaling z the same way as x. Then:
// x axis: average direction of every left→right pair const xAxis = unit(PAIRS.reduce((s, [l, r]) => add(s, sub(q3[r], q3[l])), [0, 0, 0])); // y axis: forehead top → chin, with the x component removed const down = sub(q3[CHIN], q3[FOREHEAD_TOP]); const yAxis = unit(subScaled(down, xAxis, dot(down, xAxis))); // project every point onto the face plane, origin at the nose bridge const p = q3.map((q) => { const d = sub(q, q3[NOSE_BRIDGE]); return [dot(d, xAxis), dot(d, yAxis)]; }); Averaging all the pair vectors for the x axis matters. Any single pair (say, the outer eye corners) carries that feature's own asymmetry into the axis. The average of twelve pairs is much less sensitive to any one of them.
The same axes give you head pose for free:
const roll = Math.atan2(xAxis[1], xAxis[0]); const yaw = Math.atan2(-xAxis[2], Math.hypot(xAxis[0], xAxis[1])); const pitch = Math.atan2(yAxis[2], Math.hypot(yAxis[0], yAxis[1])); We use those angles later to decide whether to trust the result.
Step 3: compare each pair against the midline
In the face frame, the midline is the average x of the seven midline points. For each pair we ask two questions: are both points the same distance from the midline, and are they at the same height?
const midX = mean(MIDLINE.map((i) => p[i][0])); const faceWidth = dist(p[L.cheekbone], p[R.cheekbone]); const pairDeviation = (l, r) => { const dx = (midX - l[0]) - (r[0] - midX); // distance-to-midline difference const dy = l[1] - r[1]; // height difference return (Math.hypot(dx, dy) / faceWidth) * 100; // % of face width }; Dividing by face width (cheekbone to cheekbone) makes the result independent of photo resolution and of how close the camera was. Each area's deviation is the mean over its pairs, and 0 means perfectly mirrored.
Note what this does not do: it doesn't fit a midline by minimizing asymmetry. The midline comes from the midline points, so a nose that leans to one side shows up as the nose sitting off-center rather than being quietly absorbed into the line.
Step 4: turn deviations into scores
A deviation of "1.2% of face width" means nothing to a user, so each area becomes a score out of 100 with an exponential:
const devScore = (dev, k) => 100 * Math.exp(-dev / k); k is set per area from a calibration sample: the median deviation in the sample maps to a score of 70. The current values:
| Area | k |
|---|---|
| Eyes | 3.229 |
| Eyebrows | 3.468 |
| Nose | 1.304 |
| Mouth | 2.921 |
| Jaw | 2.741 |
Nose has the smallest k, so its score drops fastest: in the sample the nostril wings sat closest to symmetric, so a small offset is already unusual. Eyebrows have the largest k, partly because expression moves brows more than any other feature.
The five areas are weighted equally, and the overall symmetry score is their average. On the page it's read in three bands: 85 and up is "closely mirrored", 60–84 is "well matched", and under 60 is "more difference in this photo". The wording is deliberate: no band is a grade, and none of them is a pass mark.
The calibration sample is 45 people, one quality-checked photo each, and it skews older and male. That's small, and the k values will be redone once there's real data.
Step 5: the head-turn problem
Here's the part that surprised us. The 3D frame from step 2 fully corrects roll (tilting your head sideways), so we only flag roll past 25°. It also handles small amounts of yaw (turning left or right). It does not handle yaw past a few degrees.
When we photographed the same people at slightly different angles:
- Keeping only photos within 5° of yaw, the biggest gap between two photos of the same person was 0.4 points on the full 10-point score.
- Past about 8°, gaps of 2.0 showed up, and in one case the symmetry score for the same face went from 80 to 32.
- We tried a linear correction (more yaw, more compensation). It didn't help.
Our best explanation: a turned head hides part of the far cheek and jaw. The landmark model still places points there, but it's estimating geometry the camera didn't see, and the error depends on each face's shape, not on the angle alone. No rotation can recover measurements that were never in the image.
Rejecting every photo over 5° wasn't an option either. In a set of 102 everyday face photos, 38% were turned more than 5° and 12% more than 10°, and most didn't look turned at all. So the quality gate has two levels:
yaw: { provisional: 5, reject: 10 }, // degrees pitch: { provisional: 18, reject: 28 }, roll: { provisional: 25 }, // roll is corrected; only flag extremes Between 5° and 10° you still get a result, labeled as rough; past 10° the page asks for another photo. Because symmetry depends on yaw more than any other measurement does, the symmetry page marks the whole result as rough as soon as the turn reaches 5°.
The mirrored halves are less forgiving
The page also shows two composite faces: the left half mirrored into a whole face, and the right half mirrored into a whole face. These are plain 2D canvas operations: rotate so the forehead-to-chin line is vertical, scale by cheekbone width, then draw each half twice with scale(-1, 1).
There's no 3D correction here, so a turned head makes one composite wide and the other narrow. On our sample photos, 3° looked fine and 5° was already visibly distorted, so at 5° or more the page skips the composites instead of showing a distorted face.
What the number can and can't tell you
It can tell you how far matched points sit from mirror positions in this photo, area by area. It's repeatable: the same image always gives the same score.
It can't separate face structure from how the photo was taken. Yaw, side light (which hides the true jaw edge), lens distance and a half-smile all move the number. A low score from one photo is more often the pose than the face.
It isn't a beauty verdict. Small left-right differences, which biologists call fluctuating asymmetry, are present in every face. The research does link symmetry to attractiveness: Gillian Rhodes's 2006 review in the Annual Review of Psychology named averageness, symmetry and sexual dimorphism as good candidates for biologically based standards of beauty. But it's one cue among several, and the faces people rate highest aren't perfectly symmetric either.
If you're building something similar
- Build the frame from the face, averaging all mirror pairs for the horizontal axis.
- Normalize by face width, and take the midline from midline landmarks.
- Gate on yaw. Correcting roll in 3D works; correcting yaw past a few degrees doesn't.
- Report per area, and label rough results as rough.
This article was generated by AI from our own source code and test notes, and reviewed by a human before publishing.