terminalskills-chandra-ocr

Terminalskills Chandra OCR 用于从复杂文档中提取文本,能高精度处理表格、表单、手写内容及整页布局。适用于从扫描文档提取数据、读取 PDF/图像中的复杂表格或处理手写表单的场景。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "terminalskills-chandra-ocr":https://skillpi.com/zh/skills/deepskill-f24799bcc10565aa40439afcb7a32b1252a26de0274b68f15102c16eb90bb784。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Terminalskills Chandra OCR 用于从复杂文档中提取文本,能高精度处理表格、表单、手写内容及整页布局。适用于从扫描文档提取数据、读取 PDF/图像中的复杂表格或处理手写表单的场景。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: chandra-ocr
description: >-
  Extract text from complex documents using Chandra OCR — handles tables, forms, handwriting,
  and full page layouts with high accuracy. Use when: extracting data from scanned documents,
  reading complex tables from PDFs/images, processing handwritten forms.
license: Apache-2.0
compatibility: "Python 3.10+"
metadata:
  author: terminal-skills
  version: "1.0.0"
  category: documents
  tags:
    - ocr
    - document-processing
    - tables
    - handwriting
    - data-extraction

Chandra OCR

Extract text from complex documents — tables, forms, handwriting, and full page layouts — using Chandra, a high-accuracy OCR engine built for real-world document complexity.

Overview

Chandra OCR handles the document types that trip up standard OCR: multi-column tables with merged cells, mixed print and handwriting, and complex page layouts. It outputs structured data (DataFrames, JSON) and supports GPU acceleration for batch processing.

Instructions

Installation

pip install chandra-ocr

For GPU acceleration (recommended for batch processing):

pip install chandra-ocr[gpu]

Basic Text Extraction

from chandra import OCR

ocr = OCR()

result = ocr.read("document.png")
print(result.text)

# From a PDF
result = ocr.read("report.pdf")
for page in result.pages:
    print(f"--- Page {page.number} ---")
    print(page.text)

Layout-Preserved Extraction

result = ocr.read("document.png", preserve_layout=True)

for block in result.blocks:
    print(f"Type: {block.type}")  # paragraph, table, header, handwriting
    print(f"Text: {block.text}")
    print(f"Confidence: {block.confidence:.2f}")

Table Extraction

result = ocr.read("invoice.png", extract_tables=True)

for table in result.tables:
    print(f"Table: {table.rows} rows x {table.cols} columns")
    df = table.to_dataframe()
    print(df.head())
    table.to_csv("extracted_table.csv")

Handwriting Recognition

result = ocr.read("handwritten_form.jpg", mode="handwriting")

for block in result.blocks:
    if block.type == "handwriting":
        print(f"Handwritten: {block.text} (conf: {block.confidence:.2f})")

Mixed Documents (Print + Handwriting)

result = ocr.read("filled_form.png", mode="mixed")

for block in result.blocks:
    print(f"[{block.type}] {block.text} (conf: {block.confidence:.2f})")

Batch Processing

import glob
from chandra import OCR
import json

ocr = OCR(device="cuda")
files = glob.glob("documents/*.pdf")

for file_path in files:
    result = ocr.read(file_path, extract_tables=True)
    output = {
        "file": file_path,
        "pages": len(result.pages),
        "text": result.text,
        "tables": [t.to_dict() for t in result.tables],
    }
    with open(file_path.replace(".pdf", ".json"), "w") as f:
        json.dump(output, f, indent=2)

Examples

Example 1: Extract Invoice Tables to CSV

from chandra import OCR

ocr = OCR()
result = ocr.read("invoice-2025-0342.pdf", extract_tables=True)

for i, table in enumerate(result.tables):
    df = table.to_dataframe()
    df.to_csv(f"invoice_table_{i}.csv", index=False)
    print(f"Table {i}: {table.rows} rows — columns: {list(df.columns)}")
# Output:
# Table 0: 12 rows — columns: ['Item', 'Qty', 'Unit Price', 'Total']
# Table 1: 3 rows — columns: ['Tax Type', 'Rate', 'Amount']

Example 2: Process Handwritten Medical Forms

from chandra import OCR
import requests

ocr = OCR()

result = ocr.read("patient_intake_form.jpg", mode="mixed", extract_tables=True)

extracted = {}
for block in result.blocks:
    extracted[block.label] = {
        "value": block.text,
        "confidence": block.confidence,
        "needs_review": block.confidence < 0.85,
    }

review_fields = {k: v for k, v in extracted.items() if v["needs_review"]}
print(f"Fields needing review: {list(review_fields.keys())}")
# Output:
# Fields needing review: ['allergies', 'signature']

Guidelines

  • Use device="cuda" for batch processing — 5-10x faster than CPU
  • Set dpi=300 or higher for scanned documents to improve accuracy
  • For forms with checkboxes, use mode="mixed" to detect both print and marks
  • Confidence threshold of 0.85 is a good default for human review routing
  • Pre-process images (deskew, denoise) for better results on poor-quality scans
Option Default Description
mode "auto" Detection mode: auto, print, handwriting, mixed
preserve_layout False Maintain spatial positioning of text
extract_tables False Detect and extract tables as structured data
device "cpu" Processing device: cpu or cuda
language "en" Primary language hint
dpi 300 DPI for PDF rasterization

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值88/100

亮点

  • 支持高精度处理表格、表单、手写内容及复杂布局,解决标准 OCR 难以处理的实际问题
  • 提供发票提取、医疗表单处理等端到端示例,实用性强
触发精准95/100

亮点

  • 触发描述清晰覆盖多种变体(扫描文档、PDF/图像表格、手写表单),边界明确
结构规范92/100

待提升项

  • description 内容重复 原报告严重程度:轻微

    顶层 frontmatter 和 skill_body 内部均包含 description 字段,内容一致但存在冗余

    改进建议:建议保留一处 description,避免重复

亮点

  • 文档结构完整,包含安装、基础用法、高级功能、示例和最佳实践
  • 提供多种使用模式(print/handwriting/mixed)和参数说明,便于用户快速上手
执行可靠90/100

亮点

  • 提供完整的 pip 安装命令及 GPU 加速选项
  • 覆盖主要异常处理建议(置信度阈值、图像预处理、设备选择)
  • 参数说明详细,包含默认值和用途描述
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

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

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 保存或修改文件

    先确认输出目录和同名文件是否会被覆盖;重要文件保留备份,优先写入新的输出目录。

    主文档提及 · 第 120 行
  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 34, 40 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。