UNPKG

ppu-paddle-ocr

Version:

Lightweight, probably the fastest PaddleOCR SDK in TypeScript. Runs anywhere JavaScript runs: Node.js, Bun, Deno, mobile react-native, web browsers, and browser extensions. Docker & CLI supported. The official SDK is browser-only. Accurate text detection

34 lines (33 loc) 1.62 kB
import type { Tensor } from "onnxruntime-common"; import type { Box, DebuggingOptions, RecognitionOptions } from "../../interface.js"; import type { CoreCanvas, PlatformProvider } from "../platform.js"; import type { RecognitionResult } from "../base-recognition.service.js"; /** Minimal context passed from `BaseRecognitionService` into strategy helpers. */ export type RecognitionContext = { platform: PlatformProvider; options: RecognitionOptions; debugging: DebuggingOptions; engine: "opencv" | "canvas-native"; runInference: (inputTensor: Tensor) => Promise<Tensor>; }; /** * Per-box strategy: recognize each detected box individually. */ export declare function runPerBoxStrategy(sourceCanvas: CoreCanvas, validBoxes: Array<{ box: Box; index: number; }>, ctx: RecognitionContext, processBox: (canvas: CoreCanvas, box: Box, index: number, total: number, debugPath: string, dict?: string[]) => Promise<RecognitionResult | null>, charactersDictionary?: string[]): Promise<RecognitionResult[]>; /** * Per-line strategy: merge same-line boxes and recognize per line. */ export declare function runLineStrategy(sourceCanvas: CoreCanvas, validBoxes: Array<{ box: Box; index: number; }>, ctx: RecognitionContext, charactersDictionary?: string[]): Promise<RecognitionResult[]>; /** * Cross-line strategy: bin-pack line crops by width to minimize inference count. */ export declare function runCrossLineStrategy(sourceCanvas: CoreCanvas, validBoxes: Array<{ box: Box; index: number; }>, ctx: RecognitionContext, charactersDictionary?: string[]): Promise<RecognitionResult[]>;