FFFF Flag photo problems before tracing by jasonmadigan · Pull Request #153 · tracefinity/tracefinity · GitHub
[go: up one dir, main page]

Skip to content

Flag photo problems before tracing - #153

Merged
jasonmadigan merged 6 commits into
mainfrom
150-photo-checks
Jul 30, 2026
Merged

jasonmadigan merged 6 commits into
mainfrom
150-photo-checks

Conversation

@jasonmadigan
Copy link
Copy Markdown
Collaborator

Summary

  • Flags photo problems at corner-confirmation time, before the user invests in tracing and printing. Three checks ship: camera too close (EXIF FocalLengthIn35mmFilm plus 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.
  • Focal length is extracted at upload, before re-encoding strips EXIF, and stored on the session. Checks run in POST /sessions/{id}/corners against 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.
  • Frontend shows a dismissible warning banner in the trace sidebar as soon as correction completes, with the expected oversize magnitude and a link to the photo guide. It persists through the trace and edit steps and on session reload. Non-blocking throughout.
  • Graceful no-ops everywhere: stripped EXIF skips only the camera-height check, unreadable images or degenerate quads skip cleanly, and any check failure is logged and swallowed.

Camera height uses the diagonal pinhole model: the image diagonal maps to the 43.27 mm full-frame diagonal that FocalLengthIn35mmFilm is defined against, so H = 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

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
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>
@jasonmadigan
jasonmadigan merged commit d18d9b9 into main Jul 30, 2026
4 checks passed
@jasonmadigan
jasonmadigan deleted the 150-photo-checks branch July 30, 2026 14:43
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.

Flag photo problems before tracing

1 participant

0