Most online face-shape detectors, color analysis tools, and proportion calculators follow the same pattern: you upload a selfie to a remote server, wait for a GPU queue, and hope your photo gets deleted later.
When building BodyType Report, I wanted every free measurement tool to run 100% locally in the browser—zero photo uploads, zero server GPU cost, and instant results even on mobile.
Here is the architecture we ended up with using MediaPipe Face Landmarker (WASM), TanStack Start, and Cloudflare Workers.
1. Moving 478-Point Facial Geometry Into Browser Memory
Instead of sending portraits to a backend API, we bundle the MediaPipe Face Landmarker WASM runtime and model file as static edge assets on Cloudflare.
When a user selects a photo or opens their webcam:
- The image is decoded into an
ImageBitmapstrictly in browser memory. - MediaPipe extracts 478 3D facial landmarks plus the 4×4 facial transformation matrix.
- We correct for head roll (
rollDeg) before computing any distances or angles—otherwise even a 5° head tilt breaks bilateral symmetry and canthal tilt readings. - Once the user closes the tab, the image memory is garbage-collected. Nothing ever hits our server.
You can try the live local pipeline on the Face Shape Detector or Golden Ratio Face Calculator.
2. Deterministic Math Over Black-Box "Attractiveness Scores"
A lot of face tools return arbitrary 1–10 attractiveness ratings. From an engineering (and UX) standpoint, transparent ratios are far more useful:
- Face shape: Euclidean distance to 7 anthropometric ratio prototypes (
length/cheek,forehead/cheek,jaw/cheek, and jaw corner angle), outputting both the primary match and runner-up. - Body shape: The classic FFIT (Female Figure Identification Technique) and male shoulder-to-waist ratio thresholds, rendered live as a parametric SVG silhouette on the Body Shape Calculator.
- Seasonal color analysis: Sampling balanced cheek, forehead, and brow pixel regions in CIELAB-inspired warmth and luminance space—paired with a 4-question draping quiz fallback when indoor tungsten lighting skews phone white balance (Color Analysis Quiz).
3. Solving Real-World Browser Edge Cases
Two subtle issues bit us during testing:
- React webcam ref timing: Assigning
videoRef.current.srcObject = streambefore React commits the<video>element causes a silent black frame in Safari/Chrome. Moving stream attachment into auseEffect([cameraActive])and capturing frames through an offscreen<canvas>made live camera analysis reliable across desktop and mobile. - Edge caching SSR HTML: On Cloudflare Workers, setting
Cache-Control: public, max-age=0, s-maxage=3600strictly on anonymousGETHTML pages (skipping/api,/settings, and requests with auth cookies) dropped global TTFB dramatically while keeping authenticated routes private.
Key Takeaway
If your SaaS offers free diagnostic or visual tools, pushing computer vision to WebAssembly in the browser is a massive win: $0 inference cost at scale, instant latency, and a privacy guarantee users can verify in DevTools Network tab.
Happy to answer any questions about running MediaPipe WASM with Vite/TanStack Start or deploying to Cloudflare Workers!