mac-local-ocr
v1.0.0
Published
macOS 本地 OCR CLI + Claude Code 技能(Apple Vision,零依赖,图片不出本机)
Maintainers
Readme
mac-local-ocr
macOS 本地 OCR 工具 + Claude Code 技能。基于 Apple Vision 框架,零依赖,图片不出本机。
安装(其他 Mac)
npm install -g mac-local-ocr安装过程会自动:
- 安装
ocr全局命令(universal binary,Intel / Apple Silicon 通用) - 安装 Claude Code 技能到
~/.claude/skills/ocr/(重启 Claude Code 生效)
不需要 Xcode——二进制已预编译,只依赖 macOS 自带的 Vision 框架(macOS 10.15+)。
用法
ocr # 读剪贴板图片(截图后直接识别)
ocr 截图.png # 识别文件(支持拖拽/通配符/目录)
ocr --json 截图.png # 带坐标和置信度的结构化输出
ocr --lang en 图.png # 指定语言(默认 zh-Hans + en-US)
ocr --fast 验证码.png # 快速模式从源码构建(开发)
git clone [email protected]:realpkuasule/mac-local-ocr.git
cd mac-local-ocr
npm run build # 编译 universal binary 到 bin/ocr
npm test # 手动验证:scripts/validate.sh结构:
| 文件 | 说明 |
|------|------|
| src/ocr.swift | 引擎源码 |
| scripts/build.sh | 编译 universal binary(arm64 + x86_64) |
| scripts/validate.sh | 发布前校验(构建 + 架构 + 功能) |
| scripts/install-skill.mjs | postinstall:安装 Claude Code 技能 |
| SKILL.md | Claude Code 技能定义 |
| test/ | 测试图片 |
坐标说明
--json 输出中 bbox 为归一化坐标(0~1),原点在图片左下角,y 轴向上。
像素坐标换算:px = x * width、py = y * height(从下往上)。
常见问题
ocr: command not found→ 确认 npm 全局 bin 目录在 PATH(常见位置/opt/homebrew/bin、/usr/local/bin或 npm prefix)- 识别不准 → 试试
--fast或--lang指定单语言 - 卸载:
npm uninstall -g mac-local-ocr(技能文件在~/.claude/skills/ocr/,可手动删除)
