SuperAPI AI 工具集

image-ocr

办公与效率

查看项目

更新于 10-16 06:43

技能介绍

用途:批量处理某个目录下的 JPG/JPEG 图片,将每张图片的 OCR 文本合并写入一个 Markdown 文件。适合从扫描文档、白板照片、截图中提取文字。

后端:vision 为 macOS/Apple Silicon 默认后端,通过 PyObjC 调用 Apple Vision,速度快、本地运行、GPU 加速,需安装 pyobjc-core 与 pyobjc-framework-Vision;tesseract 使用 tesseract CLI,跨平台,可借助 Pillow 做灰度、自动对比度、放大等预处理;mlx_ocr 在 Apple Silicon 上使用 MLX,需 Python 3.10+ 与 mlx-ocr,并在子进程中运行以隔离潜在 Metal 崩溃;auto 先试 vision,失败则回退 tesseract。

用法: python3 ${CLAUDE_PLUGIN_ROOT}/scripts/ocr_jpgs_to_markdown.py
--input <directory-of-jpgs>
--output <output.md>
[--backend auto|vision|tesseract|mlx_ocr]
[--start N] [--limit N]
[--languages en-US]
[--fast]
[--workers N]
[--tesseract-lang eng] [--tesseract-psm 6] [--tesseract-oem 1]
[--preprocess] [--preprocess-scale 2.0]
[--det-lang eng] [--rec-lang lat]
[--mlx-worker-python /path/to/python3.11]

主要参数:--input 为图片目录,--output 为输出 Markdown 路径,--backend 默认 auto,--start 指定排序后文件列表的起始索引(从 0 开始),--limit 限制处理数量,--languages 为 Vision 识别语言(逗号分隔,默认 en-US),--fast 使用更快但精度较低的识别级别,--workers 为并行数(默认 CPU 数),--preprocess 与 --preprocess-scale 控制 tesseract 预处理及放大倍数。

依赖:Vision 后端需 macOS 与 PyObjC;tesseract 后端需 tesseract 二进制(如 brew install tesseract);MLX 后端需 mlx-ocr 与 Python 3.10+;预处理与 MLX 需 Pillow。

限制:仅处理 JPG/JPEG 图片;具体识别效果、收费与平台支持范围请以实际环境与官方说明为准,资料未提供更多细节。