Blog · 2 min read ·
How I Built Mog Olympics: Face Landmarks, a Lot of Math, and a Leaderboard
Mog Olympics looks simple from the outside: point your camera, get a score. Under the hood, it was one of the most interesting things I've built. Here's how it works.
Step 1: Find the face
The site uses MediaPipe's face landmarker, a machine-learning model that finds a dense mesh of points on a face, hundreds of them, from the corners of the eyes to the line of the jaw. It runs entirely in the browser.
That model is the heaviest part of the site, so it only loads when you reach the camera screen. The landing page and challenge links stay fast on phones.
Step 2: Guide the poses
The camera screen walks you through a front shot and a three-quarter turn to each side. Full profile doesn't work well, because the model was trained mostly on faces looking toward the camera. A partial turn keeps it locked on while still showing the angles of your profile.
Step 3: Measure
From the landmarks, the site calculates 20 measurements. Some are ratios of distances, like jaw width over cheekbone width. Some are angles, like the gonial angle at the corner of the jaw. Side measurements are taken from both profiles and averaged.
Step 4: Score
Each measurement has a target and a tolerance, with separate targets for men and women where it makes sense. A bell-curve formula turns "how far off" into a score from 1 to 10 for that measurement. Then each one is weighted, with jaw and cheekbone measurements counting most, and everything is combined. Finally, the total is shifted down so the scale actually spreads people out.
Step 5: The leaderboard
The site is plain JavaScript built with Vite and hosted on Netlify. The leaderboard lives in a Supabase database. Scores go through a server function that checks the name, the score, and the avatar, verifies that the device owns the name, and rate-limits submissions. Posting is opt-in: nothing goes up unless you tap the button.
What I learned
- Computer vision is easy to start and hard to get right.
- Most of the work is in the edge cases: bad light, tilted heads, steep angles.
- Privacy is a design decision. Running the scan in the browser made the site both more private and cheaper to run.
Try the finished product at mogolympics.com.