古腾 OCR
oCR Javascript 库运行于 Node.js, 浏览器, React Introduct 和 C++
依据 弹出 财务报告和审定财务报表 ONNX 运行时间,支持 PP-OCRv4 模式
开始
节点
bun add @gutenye/ocr-node
import Ocr from '@gutenye/ocr-node'
const ocr = await Ocr.create()
const result = await ocr.detect('a.jpg')
浏览器
bun add @gutenye/ocr-browser
import Ocr from '@gutenye/ocr-browser'
const ocr = await Ocr.create({
models: {
detectionPath: '/assets/ch_PP-OCRv4_det_infer.onnx',
recognitionPath: '/assets/ch_PP-OCRv4_rec_infer.onnx',
dictionaryPath: '/assets/ppocr_keys_v1.txt'
}
})
const result = await ocr.detect('/a.jpg')
原生反应
bun add @gutenye/ocr-react-native
import Ocr from '@gutenye/ocr-react-native'
const ocr = await Ocr.create()
const result = await ocr.detect('a.jpg')
C++ 组合
#include "native-ocr.h"
NativeOcr* ocr = new NativeOcr(..)
auto result = ocr->detect("a.jpg");
API 参考
Ocr.create({
models?: {
detectionPath: string
recognitionPath: string
dictionaryPath: string
},
isDebug?: boolean
debugOutputDir?: string // Node only
recognitionImageMaxSize?: number // RN only
detectionThreshold?: number // RN only
detectionBoxThreshold?: number // RN only
detectionUnclipRatiop?: number // RN only
detectionUseDilate?: boolean // RN only
detectionUsePolygonScore?: boolean // RN only
useDirectionClassify?: boolean // RN only
onnxOptions?: {} // Node only. Pass to ONNX Runtime
}): Promise<Ocr>
ocr.detect(imagePath: string | {data: Uint8Array | Uint8ClampedArray | Buffer, width: number, height: number}, {
onnxOptions?: {} // Node only. Pass to ONNX Runtime
}): Promise<{texts: TextLine[], resizedImageWidth: number, resizedImageHeight: number}>
TextLine {
text: string
score: number
frame: { top, left, width, height }
}
发展
- 需要 Git LFS 来克隆 repo
brew install git-lfs
git clone [email protected]:gutenye/ocr.git
相关项目
| 名称 | 平台 | 说明 |
|---|---|---|
| 电子搜索-OCR | 电子 | |
| 相接桨 | 节点 | 复算部分不完整 |
| 欧克雷斯 | 节点 | 复算部分不完整 |
| 划板- 点- 点 | 移动, C++ |
许可证
这个项目的源代码根据 麻省理工学院 执照.
模型和字典资产 packages/models/assets 为: 没有 麻省理工学院的执照 他们来自 弹出 并一直处于 阿帕奇 - 2.0 执照.