FaceScoreLab 如何以 MediaPipe 和 Canvas 在瀏覽器本機構建面部幾何分析
How I Built Browser-Local Face Geometry With MediaPipe and Canvas
FaceScoreLab v7 在瀏覽器本機運行 MediaPipe Face Mesh,以 478 個面部地標計算幾何數據,並用 HTML Canvas 繪製對稱合成圖。平台提供六款免費工具;Full Report 在瀏覽器內分析 42 項幾何指標,計劃以 US$9.99 一次性收費,但公開結帳仍未啟用。
I built FaceScoreLab around one constraint. A portrait selected for analysis should stay in the browser that opened it. That decision shaped the whole pipeline, from landmark detection to the side-by-side symmetry images. FaceScoreLab v7, live as of November 23, 2026, runs MediaPipe Face Mesh in the browser, uses its 478 facial landmarks to calculate geometry after correcting for head roll, and draws the symmetry composites on HTML Canvas.
What I wanted from the project was something I could explain by walking through what the browser actually does. Given an image, where does the model run? What does rotating a set of coordinates fix? What can a reader see in the network log? Those questions were more useful to me while building than trying to make a score look more precise.
From a selected photo to a set of ratios
The browser opens the selected image locally and passes a working frame to MediaPipe. The detector returns landmark coordinates. From there, the application can work with points, distances, and ratios. That gives the scan two distinct jobs. The model estimates where features are in the image, and the geometry code decides how to compare those estimates. A ratio can be calculated consistently and still vary because the model placed a landmark differently in another photo.
There are six free tools using this browser-local approach. The Attractiveness Test is the entry point. The other five are the Facial Symmetry Test, PSL Scale, Face Rating, Face Shape Detector, and Golden Ratio Face Calculator. They give visitors different ways to look at the same kind of input. For instance, the golden ratio view makes sense when your question is about the size of one feature relative to another, while the symmetry view makes it easier to look at the two sides of a particular image.
Why level the eye line first?
Imagine taking a straight-on portrait and rotating the image by ten degrees. The face is unchanged, but one eye now sits higher in the image. If a left-to-right comparison assumes the head is upright, part of the result will reflect that rotation.
The roll correction uses the eye line to estimate the in-plane angle. The basic math is atan2(yRight - yLeft, xRight - xLeft). Rotate the points around a pivot by the negative of that angle, and you can calculate vertical distances and compare sides in a leveled coordinate frame. One easy detail to miss when implementing this yourself is that both axes need the same scale. If the detector normalizes each axis by its corresponding image dimension, convert back to pixels before calculating the angle.
I published the ratio and roll-correction math in a standalone, open-source companion module. It takes coordinates as input, so you can try it on synthetic points without loading a model or opening a portrait. Its examples show how to calculate facial thirds, compare paired landmarks, and measure deviation from a reference ratio. The examples use their own landmark pair choices and formulas. face-geometry-math on GitHub
What the mirrored images show
The symmetry page renders two composites on HTML Canvas. Left-Left mirrors the left half of the photo to make a full image. Right-Right does the same with the right half. Both are drawn locally. A numerical score alone gives you little to inspect, while the two images let you see how a shadow, expression, or crop might influence the impression. Facial Symmetry Test
Roll correction addresses tilt within the image. Turning your head away from the camera still changes which parts are visible and how wide each side appears. Expression, occlusion, lighting, and lens distance can also affect the input. Try using two photos taken under different lighting and look at the mirrored images before reading the numbers. A visible difference can come from the way the photo was taken.
How to check the photo upload claim
On-device analysis is compatible with ordinary network traffic. The browser can download the MediaPipe assets it needs, and a page-view request can appear in the same log. To check the free scan, look at the direction and contents of the requests around photo selection and processing.
- Open Chrome DevTools in a fresh window with extensions disabled. Select Network, enable Preserve log, and open the site.
- Keep recording while you select a non-sensitive test image and run a scan. Use a recognizable local filename if you want an extra string to look for.
- Start with Fetch/XHR, then switch back to All to catch other request types. Check request URLs and payloads for the file, encoded image data, or landmark coordinates. If a WebSocket appears, check its outbound messages too.
For this workflow, the selected photo and derived landmarks should stay out of outbound requests. The log records what happened in the run you observed. Chrome DevTools Network reference
The detailed report uses the same privacy boundary
The Full Report groups 42 geometric metrics into seven facial zones and uses rules to produce styling and lighting notes. The calculations and the notes run entirely in the browser, with no cloud AI photo upload required. The planned price is US$9.99 for a one-time purchase with no subscription. As of November 23, public checkout is still in final pre-launch activation, so live payments are currently unavailable.
A report can give more detail about a photo without giving the numbers more authority. A ratio close to 1.618 describes proximity to a mathematical reference. Beauty remains subjective, and camera setup can change the underlying measurements. FaceScoreLab is for adults aged 18 and older, for cosmetic and styling reference only. Its outputs have no clinical or medical purpose and cannot determine anyone’s attractiveness objectively. If you want to see what a single comparison can tell you, start with the Golden Ratio Face Calculator.
來源:DEV Community · dev.to