Skip to content

fix(pas-foto): head guide proportions + calibrated face detection - #302

Merged
slaveofcode merged 1 commit into
developfrom
fix/pas-foto-guide
Aug 21, 2026
Merged

fix(pas-foto): head guide proportions + calibrated face detection#302
slaveofcode merged 1 commit into
developfrom
fix/pas-foto-guide

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

Three fixes from real-device feedback (screenshots showed a skinny oval and a wrong "framing looks good").

1. The oval was far too narrow. Its width was a fraction of the frame width while its height came from the crown/chin band — so in a 3×4 frame it rendered at width/height ≈ 0.51, nothing like a head, and a different shape in each photo size. The width is now derived from the head height using an anatomical ratio (0.68), so it's head-shaped in 2×3, 3×4 and 4×6 alike. The plain ellipse is replaced by headOutlinePath() — an egg shape with a rounded cranium tapering to a chin — and the SVG viewBox now matches the photo aspect instead of stretching a square one.

2. "Framing looks good" fired while the subject was still too far away. HEAD_TO_FACE was a guessed 1.4. I ran the real MediaPipe detector on the reported photo: a 436px box against a true ~521px crown-to-chin, with the chin sitting above the box bottom. So the head was being overestimated ~17%. Now CHIN_AT = 0.88 / CROWN_ABOVE = 0.32 (→ 1.20), which also fixes vertical placement. A test pins the model to that measurement.

3. "Failed to fetch" on background removal. The background-removal and face-detection models were downloading concurrently; they now run in sequence.

Bonus, caught by a test: the vertical-position range (±0.5 frame height) was too tight — a small/distant face needs a bigger shift, leaving such photos misaligned. Widened to ±1 in both the lib clamp and the slider.

  • Tests: 1695 passing (+8 new, incl. the calibration and per-aspect oval-proportion tests) · Lint: 0 errors · Build green
  • Verified the rendered guide visually at all three photo sizes.

…ction

Three fixes from real-device feedback:

1. The oval was far too narrow. Its width came from the FRAME width while
   its height came from the crown/chin band, so in a 3x4 frame it rendered
   at a width/height of ~0.51 — nothing like a head, and a different shape
   in every photo size. The width is now DERIVED from the head height with
   an anatomical ratio (0.68), so the guide is head-shaped in 2x3, 3x4 and
   4x6 alike. The plain ellipse is replaced by headOutlinePath(), an egg
   shape with a rounded cranium tapering to the chin, and the SVG viewBox
   now matches the photo aspect instead of stretching a square one.

2. Framing feedback said 'looks good' while the subject was still too far
   away. HEAD_TO_FACE was a guessed 1.4; measuring a real detection (436px
   box vs a true 521px crown-to-chin, chin sitting above the box bottom)
   gives 1.20, split into CHIN_AT/CROWN_ABOVE so the chin is placed
   correctly too. A test pins the model to that measurement.

3. Background removal could fail with 'Failed to fetch' because the
   background-removal and face-detection models were downloaded at the
   same time; they now run in sequence.

Also widens the vertical-position range to +/-1 frame height: a test showed
a small (distant) face needs more travel than +/-0.5 allowed, which left
such photos misaligned.
@slaveofcode
slaveofcode merged commit 3347d8f into develop Aug 21, 2026
1 of 2 checks passed
@slaveofcode
slaveofcode deleted the fix/pas-foto-guide branch August 21, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant