feat(pas-foto): guided camera capture with live framing help + auto-align - #300
Merged
Conversation
…-align Users without a photo can now shoot one in the tool. The camera opens front-facing with the existing passport guide drawn over the exact crop the photo will use, and on-device face detection (the model Face Blur already ships) gives live feedback — move closer / further back / centre your head — plus an optional 3-2-1 auto-capture that only fires while the framing stays good. After capture *and* after an upload, the head is auto-aligned: a single detection sets the existing zoom/offset controls so the crown and chin land on the guide lines. Manual sliders and a re-align button remain. New pure lib foto-align.lib (framingFeedback, alignTransform, coverCropRect — 18 tests verifying the head lands on the guide to sub-pixel accuracy across aspect ratios and source orientations). useCamera.start() takes an optional facing mode (defaults unchanged). Preview is mirrored for selfie comfort but the captured file is not. Detector failure degrades to manual framing, never blocking capture. EN + ID SEO updated.
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.
Lets people make an ID photo when they don't have one yet, and makes the crop automatic for everyone.
Guided camera. "Take a photo" opens the front camera with the existing passport guide drawn over the exact region the photo will crop to (so what you frame is what you get). On-device face detection — the same MediaPipe model Face Blur already ships, so no new download — gives live feedback: move closer / further back / centre your head / ✓ framing looks good, with an optional 3-2-1 auto-capture that only counts while the framing stays good and resets if it breaks.
Auto-align. After a capture and after an upload, one detection pass sets the tool's existing
zoom/offsetYso the crown and chin land on the guide lines. The manual sliders stay, plus a "Auto-align head" button. Existing upload users benefit too.New pure lib
foto-align.lib.ts—framingFeedback,alignTransform,coverCropRect(18 tests), including tests that replay the island's compositor to prove the head lands on the guide to sub-pixel accuracy across aspect ratios (3×4, 4×6) and source orientations (portrait/landscape).Details:
useCamera.start()gained an optional facing mode (existing callers unchanged); the selfie preview is mirrored butframeToFilesaves the unmirrored frame (correct for an ID photo); if the detector fails to load it degrades to manual framing and never blocks capture; camera frames and detection never leave the device (stated in the UI and FAQ).