
DermaLens is an experimental computer vision project. Shine scores are estimates, not measurements of sebum production o
Made by
@abdul-barry-a-adam
Backend Developer | Tech Enthusiast
No posts yet. Abdul Barry A. Adam shares progress on this project here.
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.
| 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 # vitest
The 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
getUserMedia opens the front camera at an ideal 1280×720.requestAnimationFrame loop throttles analysis to roughly 10 FPS (100 ms interval).willReadFrequently, then read as ImageData.FaceLandmarker.detectForVideo runs on the original video element and returns 478 normalized landmarks.analyzeSkin builds four landmark-anchored ellipses, samples pixels, computes metrics, and returns a SkinAnalysis.meshProjection.ts to compensate for CSS mirroring and object-cover cropping 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:
0.2126R + 0.7152G + 0.0722B.(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)
SkinAnalysis| 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 |
RegionAnalysis| 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:
object-cover projection handles matching, tall, and wide viewports.Run with:
pnpm test
Add a capture of the live HUD and one with the facial mesh overlay enabled before publishing.
@mediapipe/tasks-vision, Apache-2.0).face_landmarker.task model originate from MediaPipe. See THIRD_PARTY_NOTICES.md for details.
Quizzy
Quizzy is a quiz platform where you can pick a topic and play at your own pace, or bring everyone together for a live qu
Live
qr-box-reader-extension
Scan QR codes without a phone with extension. Select a QR image on your screen and get the link
Building
ChatTalk
A real-time chatting web app, made to practice django web socket
Paused
ClueFinding
A One Piece Clue Finding app where the users inputs clues in order to get the name of the user that has the Will of D
BuildingBuilding a dev tool or hiring developers? Get seen here. Become our Sponsor
Building a dev tool or hiring developers? Get seen here. Become our Sponsor