import { Canvas } from "ppu-ocv"; import { BasePaddleOcrService } from "../core/base-paddle-ocr.service.js"; import type { PaddleOptions, RecognizeOptions } from "../interface.js"; import type { FlattenedPaddleOcrResult, PaddleOcrResult } from "../web/paddle-ocr.service.web.js"; /** * PaddleOcrService - Provides OCR functionality using PaddleOCR models. * To use this service, create an instance and call the `initialize()` method. */ export declare class PaddleOcrService extends BasePaddleOcrService { /** * Creates an instance of PaddleOcrService. * @param options - Configuration options for the service. */ constructor(options?: PaddleOptions); /** * Fetches a resource from a URL and caches it locally. * If the resource is already in the cache, it loads it from there. */ private _fetchAndCache; /** * Loads a resource from a buffer, a file path, a URL, or a default URL. */ private _loadResource; protected initSessions(): Promise; /** * Initializes the OCR service by loading models and dictionary. * This method must be called before any OCR operations. */ initialize(): Promise; /** * Checks if the service has been initialized with models loaded. */ isInitialized(): boolean; /** * Changes the detection model for the current instance. * @param model - The new detection model as a path, URL, or ArrayBuffer. */ changeDetectionModel(model: ArrayBuffer | string): Promise; /** * Changes the recognition model for the current instance. * @param model - The new recognition model as a path, URL, or ArrayBuffer. */ changeRecognitionModel(model: ArrayBuffer | string): Promise; /** * Changes the text dictionary for the current instance. * @param dictionary - The new dictionary as a path, URL, ArrayBuffer, or string content. */ changeTextDictionary(dictionary: ArrayBuffer | string): Promise; /** * Recognize text in an image, returning flattened results. * * @param image - Source image as `ArrayBuffer` or `Canvas`. * @param options - Must include `flatten: true`. * @returns Flat list of recognized text items. */ recognize(image: ArrayBuffer | Canvas, options: RecognizeOptions & { flatten: true; }): Promise; /** * Recognize text in an image, returning line-grouped results. * * @param image - Source image as `ArrayBuffer` or `Canvas`. * @param options - Optional recognition options. * @returns OCR results grouped by detected text lines. */ recognize(image: ArrayBuffer | Canvas, options?: RecognizeOptions & { flatten?: false; }): Promise; private processRecognition; /** * Delete all locally cached ONNX model files. */ clearModelCache(): void; /** * Release all ONNX sessions and free resources. */ destroy(): Promise; } export default PaddleOcrService;