khmer-pdf-ocr

OCR service specialized for Khmer (Cambodian) PDF scans, converting Khmer PDFs into editable text. Supports single-page side-by-side output, prioritizes extracting Khmer, and is compatible with documents mixing English and Khmer.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "khmer-pdf-ocr" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-01a7e016790d8b194866839effb047e3ade9c9b825cb1af387cc55360b9ea651. Verify the upstream source and version against https://skillhub.cn/skills/user_e48c1c76/khmer-pdf before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

OCR service specialized for Khmer (Cambodian) PDF scans, converting Khmer PDFs into editable text. Supports single-page side-by-side output, prioritizes extracting Khmer, and is compatible with documents mixing English and Khmer.

0 Downloads

Introduction source: third_party · user_e48c1c76 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Inputs and outputs
python3 scripts/khmer_ocr.py /path/to/cambodian_document.pdf --dpi 300 -o /path/to/output/
Software, accounts and paid services
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: khmer-ocr
version: 0.0.1
description: 专门用于高棉语(柬埔寨语)PDF 扫描件的 OCR 识别,将高棉语 PDF 转换为可编辑文本。支持单页对照输出,优先提取高棉语,兼容英柬双语混排文档。
trigger: 当用户需要识别高棉语 PDF、提取柬埔寨语文件、处理 .pdf 后缀且涉及柬埔寨/东南亚语言的文档时使用
trigger_keywords: [高棉语, 柬埔寨, khmer, cambodia, cambodg, pdf识别, 高棉文, khm]

khmer-ocr — 高棉语 PDF OCR 识别

适用场景:高棉语(柬埔寨语)PDF 扫描件 → 可编辑文本

不适用:文字层 PDF(用 lit parse --no-ocr 更高效)、中文/英文单语言扫描件(用 pdf-ocr-md)


环境依赖

已在当前环境安装,无需额外配置:

依赖 状态 安装命令
tesseract-ocr-khm ✅ 已装 apt install tesseract-ocr-khm
tesseract-ocr-eng ✅ 已装 apt install tesseract-ocr-eng
poppler-utils ✅ 已装 apt install poppler-utils
python3-pdf2image ✅ 已装 pip install pdf2image
pytesseract ✅ 已装 pip install pytesseract
Pillow ✅ 已装 pip install Pillow

工作流程

输入 PDF (高棉语扫描件)
    │
    ▼
① PDF → PNG 图片(DPI 300)
    │
    ▼
② Tesseract OCR(语言:khm + eng 混合)
    │
    ▼
③ 按页输出:khmer_text.txt(高棉语原文)

核心脚本

主脚本:scripts/khmer_ocr.py

python3 scripts/khmer_ocr.py <input.pdf> [output_dir] [--dpi 300] [--lang khm+eng]

参数说明:

  • <input.pdf> — 输入 PDF 路径(必填)
  • output_dir — 输出目录(默认:./khmer_ocr_output/)
  • --dpi 300 — 图片转 DPI,默认 300
  • --lang khm+eng — OCR 语言,默认 khm+eng(高棉语+英语双语)

输出文件(按页):

  • output_dir/page_01_khmer.txt — 第1页高棉语原文
  • output_dir/page_02_khmer.txt — 第2页高棉语原文
  • ...
  • output_dir/full_text.txt — 合并全文

使用示例

基础用法

# 识别单个 PDF
python3 scripts/khmer_ocr.py /path/to/cambodian_document.pdf

# 指定输出目录
python3 scripts/khmer_ocr.py /path/to/cambodian_document.pdf --dpi 300 -o /path/to/output/

# 指定语言(高棉语+英语双语)
python3 scripts/khmer_ocr.py /path/to/document.pdf --lang khm+eng

管道用法(结合后续翻译)

# 识别后直接 cat 查看
python3 scripts/khmer_ocr.py document.pdf -o /tmp/ocr_result/ && cat /tmp/ocr_result/full_text.txt

质量说明

因素 影响 建议
扫描 DPI DPI越高识别越准 建议 ≥ 200 DPI
页面噪点 噪点严重时准确率下降 可先做去噪预处理
双语混排 柬英混合时适当 使用 khm+eng 模式
手写体 手写文档不适用 本工具仅适用于印刷体

实测准确率:约 70-80%(柬埔寨公司章程扫描件),对正式印刷体效果较好。


关键经验教训

⚠️ 先验证,后结论:收到高棉语 PDF 时不要凭预判下结论。正确流程:

  1. 先用 lit parse --no-ocr 确认有无文字层
  2. 若为空,再实际跑 tesseract khm 输出结果验证
  3. 不要仅凭 apt-cache search 判断语言包是否存在——khm 语言包在标准 apt 源中可用,但 apt-cache search khm 搜不到(关键词差异),直接 apt-cache search tesseract-ocr 可见

⚠️ apt-cache 搜索盲区:搜索 Khmer 相关包时,用 apt-cache search tesseract-ocr | grep -i kh 或直接 apt-cache search khm(包名就是 khm),而不要搜 khmer(关键词是 khm)

故障排除

Q: apt-cache search khm 或 apt-cache search khmer 找不到包

A: 语言包名就是 khm,直接安装:
   apt install tesseract-ocr-khm
   # 不要搜 "khmer",关键词是 "khm"

Q: tesseract 报错 "Khmer language is not installed"

A: 运行以下命令安装:
   apt install tesseract-ocr-khm

Q: 识别结果全为空

A: 检查是否为真正的扫描件(无文字层):
   python3 -c "import fitz; doc=fitz.open('file.pdf'); print(any(page.get_text() for page in doc))"
   如果返回 True,说明有文字层,应该用 lit parse 而不是本工具。

Q: 识别率低,有大量乱码字符

A: 页面噪点过多,可先预处理去噪:
   convert -density 150 input.pdf -colorspace Gray -blur 0x1 output.png
   tesseract output.png result -l khm

Q: 第1页噪点极重无法识别

A: 这是扫描件封面常见问题,后续页面通常清晰。处理时:
   1. 分别处理各页,不因第1页失败放弃全稿
   2. DPI 提到 400 可能略微改善
   3. 封面内容(公司名、注册资本等)在后续页面的正文中通常会重复出现

技术说明

  • OCR 引擎:Tesseract 5.x(Leptonica 后端)
  • 语言包:tesseract-ocr-khm(Tessdata 格式,~3MB)
  • 图片转换:pdf2image(Poppler 渲染)
  • 输出编码:UTF-8 Unicode

📋 完整工作流记录(含 PDF→图片→OCR→HTML 对照输出全流程):见 references/workflow.md

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value65/100

Highlights

  • 针对高棉语 PDF OCR 识别,解决特定语言文档处理痛点
  • 具有明确实用价值,尤其适用于柬埔寨/东南亚语言用户
Trigger Precision85/100

Highlights

  • trigger 和 trigger_keywords 覆盖合理,包含高棉语、柬埔寨、pdf识别等关键词
  • 边界清晰,不易与其他 Skill 重叠
Structure and Standards90/100

Highlights

  • Phase/步骤清晰,有出口条件,含端到端示例
  • frontmatter完整,单文件≤500行,结构规范
Execution Reliability85/100

Highlights

  • 工具来源明确(tesseract-ocr-khm等),参数正确
  • 覆盖主要异常(如扫描DPI、页面噪点、双语混排、手写体等),有故障排除说明
Evidence Verifiability (mean of the first four)81/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.