Detect the page number from the scanned photo #2
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/ocr-page-number"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
When you scan a photo, the app now also tries to read the printed page number and fills the Page field with it.
42,— 17 —,[12]Seite 128,S. 12,Page 12,p. 1212 Erstes Kapitel,Erstes Kapitel 13(only if the line is at most 8 words and doesn't end in punctuation, to avoid matching body text)New logic is in
client/src/lib/pageNumber.ts(pure function, no OCR dependency);ocr.tsgetsrecognizePageNumber();NoteFormPage.tsxwires it in.Limitations
xii) aren't recognised, since the Page field only takes whole numbers.Testing
findPageNumber(footer/header/labelled numbers, body text starting or ending with numbers, low confidence, unordered input); all pass. The repo has no test setup, so these aren't committed.npm run build -w clientpasses🤖 Generated with Claude Code
After the cropped text is recognized, run a second OCR pass on the full, uncropped photo (the crop usually cuts off the header/footer) and look for a printed page number in the outermost lines: a standalone number ("42", "- 17 -"), a labelled one ("Seite 128", "p. 12"), or a number at either end of a short running header on the first line. The result fills the Page field only if it is still empty, with a hint asking the user to check it. Failures are silent; the user can still type the page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>