Repository navigation
feat(orientation): turn pages upright before OCR with --orient - #83
Merged
Merged
Conversation
Scans come in on their side or upside down, and an engine reading a page that is not upright returns nonsense. `--orient latin|armenian` on `ocr` and `batch` reads which way up a page is from its ink and turns it before the engine sees it (brief 020). Two questions, in order. Whether the lines run across or down is script-agnostic: the line-direction vote from the Empire on Trial reading site. Which way is up depends on the script, so the caller names it: for Latin, the share of a line's outer ink above it (with the plateau merge and the lines-found guard); for Armenian, which way the open sides of the letters face, after Aradhye (2005). Design research 002 found the Latin measure fails on Armenian, and 003 that the concavity measure works on it and not on Latin. Unsure means untouched: a blank leaf, a dark frame or a share within the margin of a half is read as it is and named. The margins come from the studies' saved per-page readings. The scan is never changed; the engine reads a turned PNG copy, the searchable PDF embeds that copy so its text layer lines up, and the manifest note and an `orientation` run-log event record the turn. Single-page files only. The Armenian measure needs NumPy and OpenCV, in a new `orientation` extra (already transitive through EasyOCR), which `dev` installs so the tests run in CI. The tests draw their pages, so no image needs a licence. Co-authored-by: Yvette Mankerian <yvettekm@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying tetrak with
|
| Latest commit: |
3befe10
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f677eb33.tetrak.pages.dev |
| Branch Preview URL: | https://feat-page-orientation.tetrak.pages.dev |
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.
Builds stages 1 and 2 of brief 020: turning pages upright before OCR.
What changed
--orient latin|armenianontetrak-ocr ocrandtetrak-ocr batch. It reads which way up a page is from its ink and turns the page before the engine sees it.tetrak_ocr.orientation. It asks two questions, in order:processed/byte for byte. The turn is recorded in the manifest'snotecolumn and as anorientationevent in the run log.orientationextra (NumPy, OpenCV), needed only for--orient armenian. Both packages are already transitive through EasyOCR. A missing extra stopsbatchbefore any file is touched.devnow installs the extra, so its tests run in CI; that adds OpenCV, about 40 MB, to the CI install.notecolumn is documented.ocr's body after argument handling moved into_transcribe, so it can run inside the upright block.process_filebecame a thin wrapper around_process_filefor the same reason. There are no behaviour changes without--orient.Checks
pytest -m "not slow": 492 passed, 40 of them new, on synthetic pages drawn in the tests, so no image needs a licence.ruff checkandruff format --check: clean.sphinx-build -W: clean, with the new module in the API reference.Not in this PR
🤖 Generated with Claude Code