Agent Skills
› xberg-io/xberg
› ocr-pipeline-and-quality
ocr-pipeline-and-quality
GitHubOCR处理流程与质量评估规范,涵盖多后端执行、缓存策略及精度校验。
Trigger Scenarios
需要执行或优化OCR识别流程
评估OCR结果质量与精度
配置OCR后端与缓存
Install
npx skills add xberg-io/xberg --skill ocr-pipeline-and-quality -g -y
SKILL.md
Frontmatter
{
"name": "ocr-pipeline-and-quality",
"type": "Playbook",
"paths": [
"crates\/xberg\/src\/ocr\/**",
"crates\/xberg\/src\/paddle_ocr\/**",
"crates\/xberg\/src\/sceptre_ocr\/**",
"crates\/xberg\/src\/candle_ocr\/**",
"crates\/xberg-tesseract\/**",
"crates\/xberg-paddle-ocr\/**",
"crates\/xberg-candle-ocr\/**",
"tools\/ocr-measure\/**"
],
"title": "Ocr Pipeline And Quality",
"x-ai-rulez": {
"id": "ocr-pipeline-and-quality",
"kind": "skill",
"metadata": {
"name": "ocr-pipeline-and-quality"
}
},
"description": "OCR backends, preprocessing, caches, hOCR, tables and quality comparisons."
}
OCR pipeline and quality
OCR flows through preprocessing, backend execution, structured conversion, page acceptance, and caching. Backend outputs are not interchangeable measurements.
Backends and execution
- All backends implement
OcrBackend. Tesseract is the default and is bound through the in-repocrates/xberg-tesseractC FFI crate; there is noleptessdependency. OcrBackendTypeisTesseract | PaddleOCR | Candle | Custom. Sceptre is selected by name throughCustom, not a dedicated enum variant.- Run blocking OCR work through
tokio::task::spawn_blocking, minimize runtime/FFI lock duration, and respect backend resource limits. - Check
PageOrientationHandlingbefore assuming a backend handles rotated input. - Validate ISO 639 language codes and required tessdata before execution. Language detection runs after extraction and does not choose traineddata automatically.
Configuration and cache
- Public
types::formats::TesseractConfigand internalocr::types::TesseractConfighave independent defaults. Change both and keep their synchronization test passing. - The OCR cache key combines a build-identity tag, image hash, backend, config hash, and output format. The config
hash includes
TESSERACT_RESULT_SCHEMA_VERSIONand the ordered Tesseract variable set and carries no build identity of its own, but it is not the whole key:OcrCache::generate_cache_keyprefixescache_version_tag(), which hashesCARGO_PKG_VERSION,CACHE_SCHEMA_VERSION,env!("XBERG_BUILD_ID")and the debug/release bit. Two builds from different commits therefore never share entries. - Bump
TESSERACT_RESULT_SCHEMA_VERSIONwhen unchanged image/config inputs can produce different output, or disable the cache for an A/B or revert check. - Default preprocessing is 300 DPI, deskew, and Otsu binarization. Auto-rotation, denoise, contrast enhancement, and color inversion are off unless configured. Native PSM defaults to 3; WASM defaults to 6.
Quality invariants
- Query
confidence_semantics()before interpreting confidence. Never thresholdUncalibratedoutput using a Tesseract-derived scale. - Tesseract font size is typography from hOCR
x_fsize; Sceptre/Paddle font size is a geometric detection-box proxy. Do not compare or threshold them as the same quantity. hocr_font_info=1is required for Tesseract typography; without it font sizes fall back to 12 pt. Sceptre/Paddle do not provide hOCR style fractions.accept_or_reject_ocr_pagecan discard an entire page and its structured paragraphs. Compare accepted pages before word counts. A missing dictionary-invalid ratio is unknown, not zero.- Precision is the scarce resource on the current benchmark corpus. Require an independently grounded F1 A/B for
recall-oriented rewrites; use the
benchmark-workflowskill. - Measure structural output such as headings and lists in Markdown, not Plain.
Tables and geometry
- OCR table detection clusters word bounding boxes; it does not detect ruled lines or re-OCR cells.
- Detect rows, merge words into cell tokens, then detect columns on the merged tokens. Use
reconstruct_table_with_columns; detecting columns on raw words creates spurious columns for multi-word cells. - The PDF OCR raster is normalized to MediaBox-oriented user space. OCR segments carry
rotation_degrees: 0.0; code reasoning about/Rotatepages must carry page rotation explicitly. - Preserve word-level bounding boxes, confidence, and reading order through hOCR parsing and validate a reconstructed grid before emitting Markdown.
Version History
-
844bb91
Current 2026-11-03 09:36
更新文档以符合上下文预算限制,缩短技能描述长度。
- 3be78fd 2026-10-19 16:31
-
ca15a59
2026-09-28 07:58
更正文档中关于缓存键构成的错误描述,明确缓存键包含构建身份标签以防止不同提交的缓存冲突。
- d8e4815 2026-08-28 18:30


