Settings reference
Every Settings field in ocrmd/config.py — its OCRMD_* environment variable, type, built-in default and the note written beside it in the source.
Resolution order, lowest to highest precedence:
- the defaults on
Settings
~/.config/ocrmd/config.toml
<root>/ocrmd.toml (root = OCRMD_ROOT or the project directory)
- environment variables
OCRMD_<FIELD> (e.g. OCRMD_MODEL, OCRMD_STABLE_FRAMES, OCRMD_RESOLUTION=1280x960)
- CLI options, applied by the command itself
Credentials come from .env (cwd, project root, then ~/.config/ocrmd/.env; first found wins and never overrides a variable already in the environment).
Values are validated on load and an invalid one fails fast, naming the key. In the environment a list may be comma-separated (OCRMD_OCR_ENGINES=apple_vision,rapidocr) and OCRMD_SINKS takes JSON. ocrmd.example.toml is a commented starting file; ocrmd doctor prints the effective values.
Settings
| Setting |
Environment variable |
Type |
Default |
Notes |
root |
OCRMD_ROOT |
Path |
OCRMD_ROOT, else the project directory |
data lives in the repo itself (raw/, processed/, ocr/, llm/, documents/, ocrmd.db); OCRMD_ROOT overrides |
Webcam auto-shutter
| Setting |
Environment variable |
Type |
Default |
Notes |
camera_index |
OCRMD_CAMERA_INDEX |
int |
0 |
— |
analysis_width |
OCRMD_ANALYSIS_WIDTH |
int |
320 |
— |
motion_threshold |
OCRMD_MOTION_THRESHOLD |
float |
4.0 |
mean abs diff (0-255) below which frame is "still"; C525 sensor noise ~2.7 |
stable_frames |
OCRMD_STABLE_FRAMES |
int |
8 |
undisturbed frames before capture, after ordinary noise |
settle_frames |
OCRMD_SETTLE_FRAMES |
int |
20 |
...and after the scene was handled — a hand, or the page outline moving. A page turn has to prove it has finished: the old gate fired during flips because every per-frame test can be true halfway through one (see scene.py). |
geometry_frames |
OCRMD_GEOMETRY_FRAMES |
int |
3 |
page-outline detections that must agree before the page counts as still |
geometry_tolerance |
OCRMD_GEOMETRY_TOLERANCE |
float |
0.03 |
how far it may move between them, as a fraction of the frame |
novelty_threshold |
OCRMD_NOVELTY_THRESHOLD |
int |
12 |
dHash hamming distance vs last capture |
blur_threshold |
OCRMD_BLUR_THRESHOLD |
float |
60.0 |
absolute floor for page sharpness (Laplacian variance) |
sharp_ratio |
OCRMD_SHARP_RATIO |
float |
0.55 |
...and at least this fraction of the best this scene has shown |
sharp_decay |
OCRMD_SHARP_DECAY |
float |
0.995 |
how fast that best fades, so the bar drops when the rig changes |
resolution |
OCRMD_RESOLUTION |
tuple[int, int] \| None |
— |
None = the camera's largest mode |
focus |
OCRMD_FOCUS |
str |
"continuous" |
continuous | locked | settle | off |
settle_after |
OCRMD_SETTLE_AFTER |
int |
1 |
focus=settle: lock after this many captures |
Focus is watched in the image, because the driver's own signals are useless on real webcams: isAdjustingFocus was false on all 599 frames measured on the rig this was built for, and lensPosition never left 0.0. See ocrmd/focus.py for what each of these was measured against.
| Setting |
Environment variable |
Type |
Default |
Notes |
focus_recovery |
OCRMD_FOCUS_RECOVERY |
bool |
true |
refocus the camera when the page has gone soft and stayed soft |
focus_hunt_band |
OCRMD_FOCUS_HUNT_BAND |
float |
0.06 |
relative sharpness spread over ~0.4s that means the lens is moving |
focus_soft_ratio |
OCRMD_FOCUS_SOFT_RATIO |
float |
0.45 |
of the best this rig has ever managed: below this it is out of focus |
focus_soft_frames |
OCRMD_FOCUS_SOFT_FRAMES |
int |
45 |
...for this many frames in a row before anything is done (~1.5s) |
focus_recovery_gap |
OCRMD_FOCUS_RECOVERY_GAP |
float |
6.0 |
seconds between attempts, so a refocus gets time to work |
occlusion_cover |
OCRMD_OCCLUSION_COVER |
float |
0.05 |
hand gate: fraction of the reference paper area that must vanish before the frame is "covered", and how many stuck frames before a persistent intrusion is accepted as part of the scene |
occlusion_rebaseline |
OCRMD_OCCLUSION_REBASELINE |
int |
30 |
— |
burst_frames |
OCRMD_BURST_FRAMES |
int |
3 |
frames read at the shutter; the sharpest is kept (1 = off) |
Focus bracket: shoot the same still page at several lens positions and keep the extra frames as variants, so a region the sharpest frame cannot resolve can be re-read from a different focus. Needs a camera that supports locking focus at a custom lens position (ocrmd doctor reports it).
| Setting |
Environment variable |
Type |
Default |
Notes |
focus_bracket |
OCRMD_FOCUS_BRACKET |
str |
"auto" |
auto (bracket only when the frame is not the scene's best) | always | off |
focus_bracket_shots |
OCRMD_FOCUS_BRACKET_SHOTS |
int |
3 |
lens positions in the bracket, including the one the lens is at |
focus_bracket_step |
OCRMD_FOCUS_BRACKET_STEP |
float |
0.05 |
lens-position offset between shots, on AVFoundation's 0-1 scale |
focus_bracket_settle |
OCRMD_FOCUS_BRACKET_SETTLE |
float |
0.25 |
seconds to let the lens travel before the frame is read |
focus_bracket_ratio |
OCRMD_FOCUS_BRACKET_RATIO |
float |
0.9 |
auto: bracket when sharpness is below this share of the scene's best |
focus_keep |
OCRMD_FOCUS_KEEP |
int |
2 |
variant images kept per capture (0 = capture the bracket, keep none) |
capture_cooldown |
OCRMD_CAPTURE_COOLDOWN |
float |
1.0 |
seconds between auto captures |
camera_reopen_after |
OCRMD_CAMERA_REOPEN_AFTER |
int |
40 |
consecutive failed reads before the camera is reopened |
Admission (should a capture become a page at all?)
Judged on what local OCR made of the crop, because image-quality signals measurably do not separate legible from illegible pages (see legibility.py). Rejection keeps the raw frame and creates nothing; it never applies to file ingest or to a forced (space-bar) capture.
| Setting |
Environment variable |
Type |
Default |
Notes |
admit_captures |
OCRMD_ADMIT_CAPTURES |
bool |
true |
false: every auto capture becomes a page, as before 0.6 |
admit_min_words |
OCRMD_ADMIT_MIN_WORDS |
int |
60 |
rejects 21 of the 120 scored pages, 20 of them truly illegible |
admit_min_confidence |
OCRMD_ADMIT_MIN_CONFIDENCE |
float |
0.5 |
— |
Dedup
| Setting |
Environment variable |
Type |
Default |
Notes |
near_duplicate_distance |
OCRMD_NEAR_DUPLICATE_DISTANCE |
int |
10 |
dHash prefilter (bits), within the same document only... |
near_duplicate_similarity |
OCRMD_NEAR_DUPLICATE_SIMILARITY |
float |
0.985 |
...confirmed by frame correlation; different pages measure <=0.98... |
near_duplicate_text |
OCRMD_NEAR_DUPLICATE_TEXT |
float |
0.85 |
...and by OCR token overlap, so two near-blank pages stay distinct... |
near_duplicate_detail |
OCRMD_NEAR_DUPLICATE_DETAIL |
float |
0.5 |
...falling back to high-pass image correlation when there is no OCR text |
Annotation sync (camera on already-scanned pages)
| Setting |
Environment variable |
Type |
Default |
Notes |
annotate_match |
OCRMD_ANNOTATE_MATCH |
float |
0.985 |
correlation against a stored capture before it counts as the same page |
Preprocess
| Setting |
Environment variable |
Type |
Default |
Notes |
min_page_width |
OCRMD_MIN_PAGE_WIDTH |
int |
900 |
px across one page below which body text is unreliable |
orientation_probe |
OCRMD_ORIENTATION_PROBE |
bool |
false |
Decide which way up a page is by asking OCR at all four rotations. It is the only test that works — every cheaper one measures at or near chance on real captures (see preprocess.orientation_probe) — but it is OFF by default because on this machine the extra Apple Vision traffic reliably segfaults the process inside RapidOCR's ONNX detector. That is a third-party interaction, not an ocrmd bug: the same run with ocr_engines = ["apple_vision"] is clean. Turn it on if you do not use rapidocr, or if your platform does not show the crash. |
OCR
| Setting |
Environment variable |
Type |
Default |
Notes |
ocr_engines |
OCRMD_OCR_ENGINES |
list[str] |
[] |
[] = auto: the best installed engine (+ a second one when ocr_ensemble) |
ocr_ensemble |
OCRMD_OCR_ENSEMBLE |
bool |
true |
run two engines when installed and vote (see ocr.merge) |
ocr_languages |
OCRMD_OCR_LANGUAGES |
list[str] |
["en-US"] |
Vision recognition languages; [] = automatic |
ocr_min_side |
OCRMD_OCR_MIN_SIDE |
int |
1400 |
crops are upscaled (<=3x) until the short side reaches this |
focus_swap_margin |
OCRMD_FOCUS_SWAP_MARGIN |
float |
0.1 |
a variant focus must beat the primary's line confidence by this to replace it |
focus_llm_images |
OCRMD_FOCUS_LLM_IMAGES |
int |
2 |
variant images attached to the LLM request when regions stay unresolved |
Reconcile
| Setting |
Environment variable |
Type |
Default |
Notes |
flag_threshold |
OCRMD_FLAG_THRESHOLD |
float |
0.95 |
— |
ocr_trust |
OCRMD_OCR_TRUST |
float |
0.9 |
— |
ocr_distrust |
OCRMD_OCR_DISTRUST |
float |
0.6 |
— |
suspect_threshold |
OCRMD_SUSPECT_THRESHOLD |
float |
0.35 |
min token overlap; below it the sources aren't describing the same page |
LLM
| Setting |
Environment variable |
Type |
Default |
Notes |
provider |
OCRMD_PROVIDER |
str |
"anthropic" |
— |
model |
OCRMD_MODEL |
str |
"claude-opus-5-5" |
— |
xai_model |
OCRMD_XAI_MODEL |
str |
"grok-4" |
— |
prompt_version |
OCRMD_PROMPT_VERSION |
str |
"transcribe@5" |
— |
llm_workers |
OCRMD_LLM_WORKERS |
int |
2 |
concurrent LLM calls during a scan (OCR stays serial) |
llm_timeout |
OCRMD_LLM_TIMEOUT |
float |
180.0 |
seconds per request |
llm_max_retries |
OCRMD_LLM_MAX_RETRIES |
int |
3 |
SDK-level retries on 429/5xx/connection errors |
llm_failure_limit |
OCRMD_LLM_FAILURE_LIMIT |
int |
3 |
consecutive failures before a scan drops to OCR-only ("degraded") |
llm_effort |
OCRMD_LLM_EFFORT |
str |
"medium" |
transcription is perception, not reasoning |
batch_poll_seconds |
OCRMD_BATCH_POLL_SECONDS |
int |
30 |
— |
Destinations (outbound: a read page is handed to another system)
| Setting |
Environment variable |
Type |
Default |
Notes |
sinks |
OCRMD_SINKS |
list[SinkConfig] |
[] |
Empty disables the whole path — no button, no command, nothing leaves the machine. These are the only settings in ocrmd that send page text somewhere other than the transcription provider, so the list is empty until an operator names a receiver (see ocrmd/sinks.py and the [[sinks]] example in ocrmd.example.toml; OCRMD_SINKS takes the same list as JSON). |
web_url |
OCRMD_WEB_URL |
str |
"http://127.0.0.1:8765" |
How this server refers to itself when it tells a receiver where a page image can be seen. A reviewer over there follows it back to the photograph, so it has to be reachable from a browser, not from inside a container. |
Logging
| Setting |
Environment variable |
Type |
Default |
Notes |
log_file |
OCRMD_LOG_FILE |
str |
"ocrmd.log" |
relative to root; "" disables |
log_level |
OCRMD_LOG_LEVEL |
str |
"INFO" |
— |
[[sinks]] entries
Each destination in sinks (a [[sinks]] table in ocrmd.toml, or one object in the OCRMD_SINKS JSON list) takes these keys; the receiver contract is in ocrmd/sinks.py.
| Key |
Type |
Default |
Notes |
name |
str |
required |
— |
url |
str |
required |
— |
api_key |
str |
"" |
sent as X-API-Key |
bearer |
str |
"" |
sent as Authorization: Bearer … (a receiver's user token) |
timeout |
float |
120.0 |
the receiver may run a model on the page; a person is waiting |
options |
dict[str, Any] |
{} |
defaults for the receiver's own options, e.g. |