Repository navigation
Flag photo problems before tracing - #153
Merged
Merged
Conversation
Detects camera-too-close (EXIF 35mm-equivalent focal length plus detected paper span give camera height; below 45cm a 15mm tool traces over ~3.5% oversized via H/(H-t)), paper cut off at the frame edge, and extreme keystone. Every check no-ops when its inputs are missing. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Upload extracts FocalLengthIn35mmFilm before re-encoding strips EXIF and stores it on the session. Corner correction runs the checks against the original image with the user-confirmed corners and chosen paper size, persists the warnings on the session, and returns them so the UI can flag problems before tracing. Checks are advisory: any failure is logged and skipped. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Dismissible banner in the trace sidebar surfaces the corners endpoint warnings (camera too close, paper cut off, extreme perspective) with a link to the photo guide. Warnings appear as soon as correction completes and persist through the trace and edit steps, including on session reload. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
jasonmadigan
marked this pull request as ready for review
July 30, 2026 14:21
Reject non-finite EXIF focal lengths so crafted values cannot reach sessions.json and break session reads. Replace the constant-restating threshold test with a real boundary test, move the shared corner synthesis helpers into conftest, and cover the exception-swallow paths, negative/inf/nan focal lengths, and degenerate quads. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
Session photo fields now follow the house field: T | null style, and the photo guide link derives from a shared docs base constant instead of a hardcoded repo URL. Signed-off-by: Jason Madigan <jason@jasonmadigan.com>
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.
Summary
FocalLengthIn35mmFilmplus the confirmed paper span give camera height; below 45 cm a 15 mm-thick tool traces over ~3.5% oversized via H/(H-t)), paper cut off (a corner at or beyond the frame edge), and extreme perspective (opposite-side keystone ratio above 1.35). Blur/shadow checks were deliberately left out: variance-of-Laplacian and contrast thresholds are hard to tune without a corpus of real photos and would false-positive too readily.POST /sessions/{id}/cornersagainst the original image with the user-confirmed corners and chosen paper size (no guessing from auto-detected corners), so the estimate uses trustworthy inputs. Warnings persist on the session and return in the response.Camera height uses the diagonal pinhole model: the image diagonal maps to the 43.27 mm full-frame diagonal that
FocalLengthIn35mmFilmis defined against, soH = f35 x paper_diag_mm x image_diag_px / (43.27 x paper_diag_px). Diagonal-based, so phone 4:3 vs 3:2 frame conventions don't skew it.Follow-up (separate issue if pursued): optional tool-thickness input compensating parallax by scaling polygons by (H-t)/H, now that H is stored per session.
Test evidence
backend/venv/bin/python -m pytest tests-- 283 passed (16 new unit tests for the checks and EXIF extraction, 5 new route tests including EXIF-survives-downscale and graceful no-EXIF paths)pnpm exec vitest run-- 114 passed (4 new banner component tests)make lint-- clean (0 errors; pre-existing warnings untouched)Closes #150