//#region src/types.d.ts type ExecutionProvider = "webgpu" | "webnn" | "webgl" | "wasm"; type ProviderPreference = "auto" | ExecutionProvider | readonly ExecutionProvider[]; type DictionarySource = readonly string[] | { url: string; }; interface ModelAsset { url: string; inputName?: string; outputName?: string; } interface PaddleOcrModelManifest { id: string; detection: ModelAsset; recognition: ModelAsset; dictionary: DictionarySource; detectionLimitSideLen?: number; detectionThreshold?: number; detectionBoxThreshold?: number; detectionUnclipRatio?: number; detectionMinSize?: number; recognitionImageShape?: readonly [channels: number, height: number, width: number]; } interface OrtRuntimeOptions { wasmPaths?: string | Record; wasmThreads?: number; } interface ExecutionProviderSupport { provider: ExecutionProvider; available: boolean; } interface CreatePaddleOcrOptions { manifest: PaddleOcrModelManifest; providerPreference?: ProviderPreference; autoBenchmark?: boolean; benchmarkCache?: boolean; warmup?: boolean; /** Cache downloaded models via the Cache API so they persist across page reloads. Defaults to false. */ cacheModels?: boolean; ort?: OrtRuntimeOptions; } type PPOcrV5ModelVariant = "server" | "mobile"; interface CreatePPOcrV5Options extends Omit { baseUrl: string; dictionaryUrl?: string; modelVariant?: PPOcrV5ModelVariant; detectionModelPath?: string; recognitionModelPath?: string; } interface Point { x: number; y: number; } interface OcrBox { points: readonly [Point, Point, Point, Point]; score: number; } interface OcrLine { text: string; score: number; box: OcrBox; } interface RuntimeBenchmark { provider: ExecutionProvider; latencyMs: number; } interface RuntimeSelection { provider: ExecutionProvider; candidates: readonly ExecutionProvider[]; benchmarked: boolean; benchmarks: readonly RuntimeBenchmark[]; } interface OcrImageMeta { width: number; height: number; } interface OcrResult { text: string; lines: readonly OcrLine[]; image: OcrImageMeta; runtime: RuntimeSelection; } type OcrProgressPhase = "loading_dictionary" | "loading_detection_model" | "loading_recognition_model" | "warmup" | "preprocessing" | "detecting" | "recognizing"; interface OcrProgress { phase: OcrProgressPhase; /** Batch progress for the recognizing phase. */ current?: number; total?: number; /** Bytes downloaded so far (model loading phases). */ loaded?: number; /** Total bytes to download, if known from Content-Length. */ totalBytes?: number; } type OcrProgressCallback = (progress: OcrProgress) => void; interface OcrOptions { maxRecognitionBatchSize?: number; onProgress?: OcrProgressCallback; } type OcrImageSource = ImageData | ImageBitmap | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | Blob | string; //#endregion //#region src/paddle-ocr.d.ts declare class PaddleOcrWeb { private readonly options; private detectorSession; private recognizerSession; private dictionary; private runtimeSelection; private initPromise; constructor(options: CreatePaddleOcrOptions); init(onProgress?: OcrProgressCallback): Promise; private doInit; private selectProvider; warmup(): Promise; private warmupSessions; getRuntimeSelection(): RuntimeSelection | null; ocr(source: OcrImageSource, options?: OcrOptions): Promise; private recognizeBoxes; dispose(): void; } declare function createPaddleOcr(options: CreatePaddleOcrOptions): PaddleOcrWeb; //#endregion //#region src/manifests/official.d.ts interface OfficialManifestOptions { baseUrl: string; dictionaryUrl?: string; modelVariant?: PPOcrV5ModelVariant; detectionModelPath?: string; recognitionModelPath?: string; } declare const DEFAULT_DICTIONARY_URL = "https://raw.githubusercontent.com/PaddlePaddle/PaddleOCR/main/ppocr/utils/dict/ppocrv5_dict.txt"; declare const PPOCRV5_MODEL_PATHS: { readonly detection: { readonly server: "det_server.onnx"; readonly mobile: "det_mobile.onnx"; }; readonly recognition: { readonly server: "rec_server.onnx"; readonly mobile: "rec_mobile.onnx"; }; }; declare function createPPOcrV5BrowserManifest(options: OfficialManifestOptions): PaddleOcrModelManifest; //#endregion //#region src/presets/ppocrv5.d.ts declare const DEFAULT_ORT_WASM_PATHS = "https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/"; declare const DEFAULT_MODEL_RELEASE_TAG = "models-ppocrv5-v4"; declare const DEFAULT_MODEL_BASE_URL = "https://zxc88645.github.io/ffocr/models/pp-ocrv5"; declare function createPPOcrV5(options: CreatePPOcrV5Options): PaddleOcrWeb; declare function createDefaultPPOcrV5(options?: Omit): PaddleOcrWeb; declare function ocrWithPPOcrV5(source: OcrImageSource, options: CreatePPOcrV5Options, ocrOptions?: OcrOptions): Promise; declare function ocrWithDefaultPPOcrV5(source: OcrImageSource, options?: Omit, ocrOptions?: OcrOptions): Promise; //#endregion //#region src/runtime/provider.d.ts declare function getKnownExecutionProviders(): readonly ExecutionProvider[]; declare function getExecutionProviderSupport(): readonly ExecutionProviderSupport[]; declare function getAvailableExecutionProviders(): ExecutionProvider[]; declare function isExecutionProviderAvailable(provider: ExecutionProvider): boolean; declare function supportsWebGpu(): boolean; declare function supportsWebNN(): boolean; declare function supportsWebGl(): boolean; declare function supportsWasm(): boolean; //#endregion export { type CreatePPOcrV5Options, type CreatePaddleOcrOptions, DEFAULT_DICTIONARY_URL, DEFAULT_MODEL_BASE_URL, DEFAULT_MODEL_RELEASE_TAG, DEFAULT_ORT_WASM_PATHS, type ExecutionProvider, type ExecutionProviderSupport, type ModelAsset, type OcrBox, type OcrImageSource, type OcrLine, type OcrOptions, type OcrProgress, type OcrProgressCallback, type OcrProgressPhase, type OcrResult, PPOCRV5_MODEL_PATHS, type PPOcrV5ModelVariant, type PaddleOcrModelManifest, PaddleOcrWeb, type ProviderPreference, type RuntimeSelection, createDefaultPPOcrV5, createPPOcrV5, createPPOcrV5BrowserManifest, createPaddleOcr, getAvailableExecutionProviders, getExecutionProviderSupport, getKnownExecutionProviders, isExecutionProviderAvailable, ocrWithDefaultPPOcrV5, ocrWithPPOcrV5, supportsWasm, supportsWebGl, supportsWebGpu, supportsWebNN }; //# sourceMappingURL=index.d.mts.map