Urgent.News

What's breaking now, across thousands of outlets.

Tech

Measuring face symmetry in the browser with MediaPipe's 478 landmarks (no upload)

Most "face symmetry" tools upload your photo to a server and send back a number. I wanted to see how far I could get with everything running on the device: the photo never leaves the browser, and the measurement is plain geometry you can read and check. This post walks through the approach: getting landmarks with MediaPipe, fixing head tilt, refusing to score a turned head, and turning raw…

The article explains how to measure face symmetry using MediaPipe's Face Landmarker in the browser without uploading any photos. The process begins by loading the necessary libraries and initializing the landmarker with the appropriate options. The landmarker returns 478 points per detected face, including facial landmarks and iris centers. The article emphasizes the importance of using the same version of the WASM file to avoid runtime errors.

Next, the article discusses converting the normalised landmarks to pixel space, as the original coordinates are skewed due to the aspect ratio of the image. A simple mapping function is provided to scale the coordinates based on the image width and height.

The author then addresses head tilt, which can affect the accuracy of the measurements. To correct for tilt, the roll angle is calculated using the horizontal distance between the left and right iris centers. This roll angle is then used to rotate all points around the center of the face, effectively leveling the head. The irises are preferred over inner eye corners for this purpose as they are detected more consistently.

Finally, the article explains how to deal with head turn, which cannot be corrected from a single photo. A turned head (yaw) is identified by comparing the horizontal distance from the nose bridge to each side of the face. If this distance is significantly different, the face is considered turned, and no symmetry score is assigned. By performing these steps entirely in the browser, the tool avoids the need to upload photos to a server, ensuring privacy while still providing an accurate measurement of face symmetry.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 15 October →