fix(pas-foto): head guide proportions + calibrated face detection - #302
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 SVGviewBoxnow 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_FACEwas 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%. NowCHIN_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.