@gutenye/ocr-models

中文文档
1.4.2发布于 2024/05/21MITES Module零依赖近 30 天下载 15万

Guten OCR is a high accurate text detection (OCR) Javascript/Typescript library that runs on Node.js, Browser, React Native and C++. Based on PaddleOCR and ONNX runtime

原始使用文档
文档目录8 节
  1. Getting Started
  2. Node
  3. Browser
  4. React Native
  5. C++
  6. API Reference
  7. Development
  8. Related Projects

Guten OCR

Demo | Roadmap

an OCR Javascript library runs on Node.js, Browser, React Native and C++

Based on PaddleOCR and ONNX Runtime, supports PP-OCRv4 model

Getting Started

Node

Example

bun add @gutenye/ocr-node
import Ocr from '@gutenye/ocr-node'
const ocr = await Ocr.create()
const result = await ocr.detect('a.jpg')

Browser

Example

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')

React Native

Example

bun add @gutenye/ocr-react-native
import Ocr from '@guenye/ocr-react-native'
const ocr = await Ocr.create()
const result = await ocr.detect('a.jpg')

C++

Example

#include "native-ocr.h"
NativeOcr* ocr = new NativeOcr(..)
auto result = ocr->detect("a.jpg");

API Reference

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, { 
  onnxOptions?: {}     // Node only. Pass to ONNX Runtime
}): Promise<Result>

Development

  • Requires Git LFS to clone the repo
brew install git-lfs 
git clone [email protected]:gutenye/ocr.git
NamePlatformsNote
eSearch-OCRElectron
paddleocr-onnxNodeRecogination part is incomplete
ocrjsNodeRecogination part is incomplete
Paddle-Lite-DemoMobile, C++

版本与发布记录

@gutenye/ocr-models 共发布 5 个版本,首次发布于 2024/05/08;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.4.2latest2024/05/212 年前
1.4.02024/05/202 年前
1.3.12024/05/202 年前
1.2.22024/05/082 年前
1.2.12024/05/082 年前

关于 @gutenye/ocr-models 的常见问题

@gutenye/ocr-models 是什么?

Guten OCR is a high accurate text detection (OCR) Javascript/Typescript library that runs on Node.js, Browser, React Native and C++. Based on PaddleOCR and ONNX runtime

如何安装 @gutenye/ocr-models?

在项目目录运行 npm install @gutenye/ocr-models,或使用 pnpm add / yarn add / bun add。

@gutenye/ocr-models 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/gutenye__ocr-models 是否存在。

@gutenye/ocr-models 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gutenye/ocr-models 可以商用吗?

@gutenye/ocr-models 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@gutenye/ocr-models 的下载量有多少?

根据 npm 官方下载统计,@gutenye/ocr-models 在 2026/10/17 – 2026/11/15 这 30 天内被下载 150,048 次,日均约 5,002 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gutenye/ocr-models 还在维护吗?

最新版本 1.4.2 发布于 2024/05/21(2 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/05/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。