Skip to content

feat(pas-foto): guided camera capture with live framing help + auto-align - #300

Merged
slaveofcode merged 1 commit into
developfrom
feat/pas-foto-camera
Aug 21, 2026
Merged

feat(pas-foto): guided camera capture with live framing help + auto-align#300
slaveofcode merged 1 commit into
developfrom
feat/pas-foto-camera

Conversation

@slaveofcode

Copy link
Copy Markdown
Owner

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/offsetY so 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.tsframingFeedback, 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 but frameToFile saves 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).

  • Tests: 1688 passing (+18) · Lint: 0 errors · Build: both pas-foto pages (EN+ID SEO) built

…-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.
@slaveofcode
slaveofcode merged commit 697e13b into develop Aug 21, 2026
1 of 2 checks passed
@slaveofcode
slaveofcode deleted the feat/pas-foto-camera branch August 21, 2026 04:06
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