DermaLens is a browser-based facial shine analyzer. It uses the webcam and MediaPipe Face Landmarker to estimate surface shine across four facial zones in real time. All image processing happens locally in the browser — no frames are uploaded.
Note: DermaLens estimates specular shine (surface reflection). It does not measure sebum production and is not a medical or diagnostic device.
- Fullscreen mirrored camera feed with floating analysis HUD.
- Real-time face detection with MediaPipe Face Landmarker; GPU acceleration with automatic CPU fallback.
- Four-zone shine analysis: forehead, nose, right cheek, left cheek.
- Optional facial mesh overlay for debugging/visualization.
- Frame-quality detection (pose, face size, blur, lighting) and per-reading confidence.
- Temporal smoothing to reduce flicker between frames.
- Local WASM/model assets — works offline after install.
| Concern | Technology |
|---|---|
| UI | React 19, TypeScript, Tailwind CSS 4 |
| Build | Vite 8 |
| Face tracking | @mediapipe/tasks-vision 1.2.3 |
| Icons | lucide-react |
| Tests | Vitest |
pnpm install
pnpm dev # start dev server
pnpm build # typecheck + production build
pnpm lint # eslint
pnpm test # vitestThe MediaPipe WASM files and model are committed under public/mediapipe/, so no CDN fetch is required at runtime. Paths are resolved through import.meta.env.BASE_URL, so subpath deployments work.
src/
├── App.tsx Fullscreen camera layout + HUD composition
├── index.css Tailwind entry + global styles
├── hooks/
│ └── useSkinScanner.ts Camera lifecycle, scan loop, mesh overlay drawing
├── lib/
│ ├── faceLandmarker.ts MediaPipe initialization (local WASM/model)
│ ├── skinAnalysis.ts Region construction + photometric scoring
│ ├── meshProjection.ts object-cover/mirror projection for the mesh
│ ├── skinAnalysis.test.ts Algorithm tests with synthetic images
│ └── meshProjection.test.ts Projection math tests
└── types/
└── skin.ts Analysis, region, and quality types
public/mediapipe/
├── wasm/ MediaPipe vision WASM loader + binaries
└── models/face_landmarker.task Face landmark model
getUserMediaopens the front camera at an ideal 1280×720.- A
requestAnimationFrameloop throttles analysis to roughly 10 FPS (100 ms interval). - Each frame is drawn into a hidden 320×240 2D canvas with
willReadFrequently, then read asImageData. FaceLandmarker.detectForVideoruns on the original video element and returns 478 normalized landmarks.analyzeSkinbuilds four landmark-anchored ellipses, samples pixels, computes metrics, and returns aSkinAnalysis.- The result is blended with the previous analysis for temporal stability and rendered in the HUD.
- If mesh display is enabled, landmarks are projected through
meshProjection.tsto compensate for CSS mirroring andobject-covercropping before being drawn.
Regions are not fixed percentages of a face box. They are derived from MediaPipe Face Mesh landmarks (skinAnalysis.ts:30):
| Region | Anchors | Excluded areas |
|---|---|---|
| Forehead | Forehead top (10), glabella (168) | Eyebrow centers (105, 334) |
| Nose | Glabella (168), nose tip (4), alae (98, 327) | Nostrils |
| Right cheek | Cheek surface (205) | Right eye, mouth corner (61) |
| Left cheek | Cheek surface (425) | Left eye, mouth corner (291) |
Face scale comes from the face oval landmarks (234, 454, 10, 152). Ellipses are clamped to the image bounds. Pixels inside exclusion ellipses are skipped so eyes, brows, nostrils, and mouth corners do not bias the reading.
For every accepted pixel inside a region:
- sRGB channels are converted to linear light with the standard transfer function.
- Luminance uses Rec.709 coefficients:
0.2126R + 0.7152G + 0.0722B. - Saturation uses HSV-style
(max - min) / max.
The region's own median luminance, 90th-percentile luminance, and median saturation are used as local baselines. This makes the measurement relative to the current skin and lighting rather than dependent on absolute image brightness.
A pixel counts as a specular highlight when:
Y > max(medianY × 1.45 + 0.01, medianY + 0.07)
S < clamp(medianS × 0.72, 0.08, 0.34)
Where Y is linear luminance and S is saturation.
highlightRatio = highlightPixels / totalPixels
contrast = clamp((p90Y - medianY) / 0.28, 0, 1)
score = clamp(highlightRatio × 230 + contrast × 30, 0, 100)
The overall score is the arithmetic mean of the four region scores.
Four frame-quality signals are computed:
| Signal | Definition |
|---|---|
| Pose quality | Nose-offset from eye/mouth midpoint, normalized by face size |
| Size quality | Face width relative to frame width |
| Sharpness quality | Variance of the Laplacian over the 320×240 image |
| Lighting quality | Median brightness plus clipped-pixel ratio |
The worst failing signal determines the frame quality label: too-small, poor-pose, blurry, poor-lighting, or good.
Confidence is a weighted blend:
0.22 × pose + 0.18 × size + 0.20 × sharpness + 0.25 × lighting + 0.15 × sampled-area
Low-confidence readings are still shown but flagged in the UI. Temporal smoothing uses an alpha that grows with confidence:
alpha = clamp(0.18 + confidence × 0.35, 0.18, 0.55)
| Field | Type | Meaning |
|---|---|---|
overallScore |
number |
Mean shine score, 0–100 |
regions |
RegionAnalysis[] |
Four per-zone results |
confidence |
number |
Reliability of the reading, 0–1 |
quality |
FrameQuality |
Worst-frame-quality classification |
timestamp |
number |
Date.now() at analysis time |
| Field | Type | Meaning |
|---|---|---|
region |
SkinRegion |
forehead, nose, leftCheek, rightCheek |
label |
string |
Human-readable zone name |
score |
number |
Regional shine score, 0–100 |
brightness |
number |
Mean gamma-space luminance, 0–255 |
highlightRatio |
number |
Fraction of pixels classified as specular, 0–1 |
contrast |
number |
Normalized p90–median luminance spread, 0–1 |
confidence |
number |
Reliability for this zone, 0–1 |
| Score | Label |
|---|---|
| 0–44 | Low shine |
| 45–74 | Moderate shine |
| 75–100 | High shine |
These bands are heuristic, not clinical thresholds.
The Facial Mesh toggle draws MediaPipe tessellation and contour connections on a transparent canvas above the video. Because the video is CSS-mirrored and uses object-fit: cover, raw normalized landmarks cannot be drawn directly. projectLandmarksToViewport compensates for both before drawing.
Tests live beside the modules they cover and use synthetic ImageData plus synthetic landmark sets:
- Shine scores increase when specular highlights are added.
- Scores stay relatively stable under global brightness changes.
- Anatomical cheek labels map correctly.
- Blurry, profile, and too-small frames are flagged.
- Temporal smoothing reduces abrupt score changes.
object-coverprojection handles matching, tall, and wide viewports.
Run with:
pnpm testAdd a capture of the live HUD and one with the facial mesh overlay enabled before publishing.
- Face tracking is powered by Google MediaPipe Face Landmarker (
@mediapipe/tasks-vision, Apache-2.0). - The bundled WASM runtime and
face_landmarker.taskmodel originate from MediaPipe. See THIRD_PARTY_NOTICES.md for details. - The project is licensed under the MIT License.
- Shine, sweat, water, makeup, and other specular reflections are visually similar; the algorithm cannot distinguish their causes.
- No skin-tone or camera calibration is performed.
- Strong backlighting, flash, or automatic exposure changes can reduce confidence.
- Regions are landmark-anchored but still elliptical approximations; hair, glasses, or occlusions can affect readings.
- Results are estimates intended for experimentation and aesthetic self-observation, not medical assessment.