Skip to content

Latest commit

 

History

History
46 lines (29 loc) · 1.08 KB

File metadata and controls

46 lines (29 loc) · 1.08 KB

@enfpdev/node-uni-ocr

CI

Description

@enfpdev/node-uni-ocr is a native Node.js library that brings system-level OCR (Optical Character Recognition) to Node.js and Electron by porting the uniOCR engine (written in Rust) via napi-rs.

It enables easy, cross-platform OCR functionality (Windows, macOS, and experimental WASI/Linux) without requiring users to set up complex build tools or environments.


Installation

pnpm add @enfpdev/node-uni-ocr
# or
npm install @enfpdev/node-uni-ocr

Usage

ESM (import) Example

import { recognize } from '@enfpdev/node-uni-ocr';
import fs from 'fs';

// OCR from file path
const result = await recognize('test.png');
console.log(result.text, result.confidence);

// OCR from buffer
const buffer = fs.readFileSync('test.png');
const result2 = await recognize(buffer, {
  languages: ['en', 'ko'],
  confidence_threshold: 0.5,
  timeout: 10,
});
console.log(result2.text);