CLI reference¶
Every
ocrmdcommand, argument and option with its default — read from the typer app inocrmd/cli.py, so it cannot drift from the code.
Run a command as ocrmd <command> (the [project.scripts] entry point) or python -m ocrmd <command>; ocrmd <command> --help prints the same options. Defaults shown are the built-in ones: several (--camera, --focus, --provider, --model, --admit, --focus-bracket) follow the settings when ocrmd.toml or an OCRMD_* variable changes them. Typer also adds --install-completion and --show-completion to the top level.
Global options¶
Given before the command: ocrmd --debug verify.
| Option | Type | Default | Description |
|---|---|---|---|
--debug |
flag | off | print full tracebacks and debug logs |
--quiet, -q |
flag | off | errors only on the console |
Commands¶
| Command | What it does |
|---|---|
scan |
Auto-capture pages from the webcam and process them incrementally. |
annotate |
Watch already-scanned pages and fold what you write on the paper into the Markdown. |
etl |
Extract structured data from a scanned document with a declarative pipeline. |
read |
Read one region of a page harder than the page itself was read. |
send |
Hand a page you have read to a destination — a study platform, a knowledge base, anything that speaks the sink contract (ocrmd/sinks.py; ocrmd sinks lists what is configured). |
sinks |
List the destinations a page can be sent to, and the options each one takes. |
library |
The inventory: every document scanned into this root, what is known about it, how far along it is. |
search |
Full-text search across every page ever scanned, or one document. |
export |
Write a document in another shape: the built Markdown, plain text, one JSON object, or one JSON object per page. |
index |
Rebuild the search index from the page files. |
reconstruct |
Rebuild pages from their Markdown as SVG + LaTeX, and score them against the original crop. |
ingest |
Ingest image files or PDFs (png/jpg/tiff/webp, pdf with the pdf extra) as pages. |
verify |
(Re)run missing/stale stages — e.g. the LLM pass for pages scanned with --no-llm or while offline. |
reprocess |
Re-derive pages from the raw captures with the current preprocessing pipeline. |
review |
Step through flagged disagreements: pick the OCR or the LLM reading, type your own, or skip. |
status |
Per-page status: what needs a re-shoot, a review, or an LLM pass — and why. |
delete |
Delete pages (or a whole document): database rows, artifacts, page files — and the raw capture when no page refers to it any more. |
build |
Regenerate document markdown + nav links from page files (and document.yaml). |
serve |
Run the web UI: live scanning, page browser, review, jobs, metadata — at http://127.0.0.1:8765. |
ocr-bench |
Score local OCR against the LLM transcriptions in the store (bag-of-words F1 per page). |
doctor |
Show engines, cameras, credentials, configuration, database health and spend. |
scan¶
Auto-capture pages from the webcam and process them incrementally.
The shutter fires when the scene has settled — still, focused, unobstructed, and with the page outline holding its position — and the page is new and sharp. After a hand or a moved page it waits longer, so a page turn is not captured halfway through. A capture no OCR engine can read is refused rather than made into a page (--no-admit keeps the old behaviour; ocrmd status lists what was refused). A soft capture is then re-shot at several lens positions (--focus-bracket) and the extra exposures travel with the page, so text no single focus resolves is re-read from another one instead of guessed at. Preview keys: r rotate, ± zoom, wasd/arrows pan, f/F focus, 0 reset, space force capture, q quit. The view is saved per camera.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--camera |
text | 0 |
index or device-name substring, e.g. c525 |
--no-llm |
flag | off | capture + OCR only; fill in the LLM pass later with ocrmd verify |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
--preview / --no-preview |
switch | --preview |
— |
--rotate |
integer | — | initial rotation 0/90/180/270 (overrides saved view) |
--zoom |
number | — | initial digital zoom, e.g. 2.0 (overrides saved view) |
--focus |
text | continuous |
continuous | locked | settle (lock after the first capture) | off |
--admit / --no-admit |
switch | --admit |
refuse automatic captures no OCR engine can read, instead of making a page of them (forced captures are always kept) |
--focus-bracket |
text | auto |
shoot each page at several lens positions: auto (only when the frame is not the sharpest the scene has shown) | always | off |
--resolution |
text | — | WxH, e.g. 1280x960; default is the largest mode |
--title |
text | — | document title (stored in document.yaml) |
--tag |
text, repeatable | — | tag for document.yaml; repeatable |
--project |
text | — | project name for document.yaml |
--duration |
number | — | stop after this many seconds (unattended runs) |
--max-pages |
integer | — | stop after this many captures |
annotate¶
Watch already-scanned pages and fold what you write on the paper into the Markdown.
Hold a scanned page under the camera and underline, highlight, strike through or write a margin note. The page is recognised, the new marks are diffed against the stored crop, and the page file is updated. Underlines and highlights cost nothing — the word positions are already on disk — so only handwriting reaches the model, and only when there is some.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--camera |
text | 0 |
index or device-name substring |
--no-llm |
flag | off | skip handwriting; marks still sync free |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
--dry-run |
flag | off | report what would change, write nothing |
--preview / --no-preview |
switch | --preview |
— |
--duration |
number | — | — |
--max-pages |
integer | — | stop after this many looks |
etl¶
Extract structured data from a scanned document with a declarative pipeline.
map / filter / extract / reduce / resolve / split / unnest / sample / crosscheck over the document's pages, blocks or figures, each an LLM prompt and an output schema (DocETL's operator model — see ocrmd/etl.py). Every output row carries the page — and, from blocks, the rectangle — it came from; every operator's answers are cached and versioned by its prompt, so changing one operator re-runs one operator. A pipeline may write back into the page files, the page model or document.yaml instead of a spreadsheet (output.type: frontmatter | layout | document).
PIPELINE may be a file, or the name of a bundled one: figures, components, references, glossary, receipts, cases.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--pipeline, -p |
path | required | the pipeline spec (YAML) |
--out |
path | — | write here instead of documents/<doc>/extracted/ |
--limit |
integer | — | only the first N pages (try a pipeline cheaply) |
--status |
text, repeatable | — | only pages with this status; repeatable |
--dry-run |
flag | off | show the prompts and the call count, spend nothing |
--no-cache |
flag | off | ignore cached answers and ask again |
--export-docetl |
path | — | write a DocETL pipeline + dataset here instead of running |
--no-llm |
flag | off | run only the operators that cost nothing |
--source |
text | — | pages | blocks | figures | extracted:<name> (overrides the spec) |
--score |
path | — | a JSON list of expected rows; report precision/recall on --score-key |
--score-key |
text | name |
the field --score matches rows on |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
read¶
Read one region of a page harder than the page itself was read.
The same thing the web UI does when you drag a box on a page image: the rectangle is cut out of the flat rendering, enlarged on its own terms and re-read. Nothing is stored — this answers "what does that word say", and the answer goes to you, not into the page file.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--page |
integer | required | page sequence |
--region |
text | 0,0,1,1 |
x,y,w,h as fractions of the page (0-1) |
--llm |
flag | off | also ask the model about this region (costs tokens) |
--ask |
text | — | what to ask about the region, instead of 'transcribe it' |
--save |
path | — | write the enlarged crop here, as it was read |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
send¶
Hand a page you have read to a destination — a study platform, a knowledge base, anything that speaks the sink contract (ocrmd/sinks.py; ocrmd sinks lists what is configured).
The text goes out, the photograph does not: the receiver gets ocrmd's reconciled reading, the page's provenance (document, page, page id, both agreement scores, a link back to the image) and the document's catalogue entry. Nothing here is written and no stage is marked — the same contract as ocrmd read. --region reads a box first and sends that reading, which is what to reach for when one item on a crowded page came out badly.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--page |
integer | required | page sequence |
--to |
text | "" |
destination name (see ocrmd sinks); may be omitted when only one is configured |
--option, -o |
text, repeatable | — | key=value for one of the receiver's options; repeatable |
--region |
text | — | x,y,w,h fractions: read this box first and send that reading |
--dry-run |
flag | off | show the envelope that would be sent, send nothing |
sinks¶
List the destinations a page can be sent to, and the options each one takes.
| Option | Type | Default | Description |
|---|---|---|---|
--probe / --no-probe |
switch | --probe |
ask each receiver for its descriptor |
library¶
The inventory: every document scanned into this root, what is known about it, how far along it is.
| Option | Type | Default | Description |
|---|---|---|---|
--json |
flag | off | machine-readable |
--all |
flag | off | also documents with no pages yet |
search¶
Full-text search across every page ever scanned, or one document. Each hit names its page.
| Argument | Type | Description |
|---|---|---|
QUERY |
text | words to find; quote a phrase; word* for a prefix |
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | only this document |
--limit |
integer | 20 |
most hits to show |
--json |
flag | off | — |
export¶
Write a document in another shape: the built Markdown, plain text, one JSON object, or one JSON object per page. Every shape keeps the page ids, so a consumer can always come back to the photograph.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | document slug; default every document |
--format, -f |
text | md |
md | txt | json | jsonl |
--out |
path | — | write here instead of <root>/export/<slug>/<slug>.<fmt> (one document only) |
index¶
Rebuild the search index from the page files. Search does this on its own for pages whose file changed; this is for after restoring a backup, or to be sure.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | document slug; default every document |
--force |
flag | off | re-read every page file, not just the changed ones |
reconstruct¶
Rebuild pages from their Markdown as SVG + LaTeX, and score them against the original crop.
The round trip is the check: anything the transcription lost — a heading flattened, a table turned to prose, a figure nobody mentioned — shows up as a difference between the rebuilt page and the photograph it came from. fidelity is that difference as one number, 0 to 1.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--page |
integer | — | one page sequence; default every page |
--out |
path | reconstructed |
directory for the .svg/.tex/.png |
--pdf |
flag | off | also compile the LaTeX (needs a TeX engine) |
--review |
flag | off | ask the model what the rebuild lost (costs tokens) |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
ingest¶
Ingest image files or PDFs (png/jpg/tiff/webp, pdf with the pdf extra) as pages.
| Argument | Type | Description |
|---|---|---|
PATHS |
path, one or more | — |
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--no-llm |
flag | off | capture + OCR only |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
--watch |
flag | off | keep watching the directory for new files (Ctrl-C to stop) |
--title |
text | — | — |
--tag |
text, repeatable | — | — |
--project |
text | — | — |
verify¶
(Re)run missing/stale stages — e.g. the LLM pass for pages scanned with --no-llm or while offline.
Without --refresh a completed LLM pass is always reused, whatever prompt version produced it: a version bump must never silently spend tokens on a whole book.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | — |
--flagged-only |
flag | off | re-run only pages already marked flagged |
--refresh |
flag | off | also re-run pages whose LLM pass used an older prompt version (costs tokens) |
--batch |
flag | off | send the LLM pass through the Batches API (half price, up to hours of latency) |
--wait / --no-wait |
switch | --wait |
with --batch: poll until the batch ends and collect it |
--collect |
flag | off | collect batches submitted earlier with --batch --no-wait |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
reprocess¶
Re-derive pages from the raw captures with the current preprocessing pipeline.
Use after upgrading ocrmd: page ids come from the processed image, so improved cropping, rotation or spread-splitting produces different pages. Cached OCR/LLM results for the old pages are discarded (the LLM pass re-runs and costs tokens); raw captures are never touched. Human-edited page files are also replaced — export them first if they matter.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | — |
--no-llm |
flag | off | — |
--provider |
text | anthropic |
— |
--model |
text | claude-opus-5-5 |
— |
--yes, -y |
flag | off | skip the confirmation prompt |
review¶
Step through flagged disagreements: pick the OCR or the LLM reading, type your own, or skip.
A page with no disagreements left is signed off as reviewed; the pipeline then keeps its body on later runs. Answers: o=OCR l=LLM t=type k=keep unresolved s=skip page q=quit. (The web UI — ocrmd serve — does the same with the page image alongside.)
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--who |
text | reviewer |
reviewer name recorded in the page |
--list |
flag | off | print the open disagreements and exit |
status¶
Per-page status: what needs a re-shoot, a review, or an LLM pass — and why.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | — |
--all |
flag | off | list every page, not just problems |
delete¶
Delete pages (or a whole document): database rows, artifacts, page files — and the raw capture when no page refers to it any more. Irreversible; the web UI offers the same with confirmations.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | required | document slug |
--page, -p |
integer, repeatable | — | sequence number(s) to delete; repeatable |
--whole-capture |
flag | off | also delete the other half of each spread |
--all |
flag | off | delete the whole document |
--keep-raw |
flag | off | keep raw captures that nothing refers to any more |
--yes, -y |
flag | off | skip the confirmation prompt |
build¶
Regenerate document markdown + nav links from page files (and document.yaml).
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | — |
serve¶
Run the web UI: live scanning, page browser, review, jobs, metadata — at http://127.0.0.1:8765.
| Option | Type | Default | Description |
|---|---|---|---|
--host |
text | 127.0.0.1 |
bind address; keep it local, there is no authentication |
--port |
integer | 8765 |
— |
--open / --no-open |
switch | --open |
open the UI in a browser |
--allow-remote |
flag | off | allow a non-loopback --host; the UI has no authentication, so anyone who can reach the port can read your scans |
ocr-bench¶
Score local OCR against the LLM transcriptions in the store (bag-of-words F1 per page).
Uses every page that has a legible model transcription; the numbers that chose the default engines are in ocr.py. Run it after installing an engine or changing the camera to see whether it paid off.
| Option | Type | Default | Description |
|---|---|---|---|
--doc |
text | — | — |
--engines, -e |
text | — | engine set to measure, e.g. apple_vision or apple_vision+rapidocr (default: configured) |
--compare |
flag | off | measure every installed engine alone and every pair |
--limit |
integer | — | only the first N reference pages |
--verbose, -v |
flag | off | one line per page |
doctor¶
Show engines, cameras, credentials, configuration, database health and spend.
| Option | Type | Default | Description |
|---|---|---|---|
--costs / --no-costs |
switch | --no-costs |
— |