import type { InferenceSession } from "onnxruntime-common"; import type { Box, DebuggingOptions, ProcessingEngine, RecognitionOptions, RecognitionStrategy } from "../interface.js"; import type { CoreCanvas, PlatformProvider } from "./platform.js"; /** * A single recognized text item with its bounding box and confidence. */ export type RecognitionResult = { /** The recognized text string. */ text: string; /** Bounding box of the text region in the original image coordinates. */ box: Box; /** Recognition confidence score (0–1). */ confidence: number; }; /** * Service for detecting and recognizing text in images */ export declare class BaseRecognitionService { protected readonly options: RecognitionOptions; protected readonly debugging: DebuggingOptions; protected readonly session: InferenceSession; protected readonly platform: PlatformProvider; protected readonly engine: ProcessingEngine; constructor(platform: PlatformProvider, session: InferenceSession, options?: Partial, debugging?: Partial, engine?: ProcessingEngine); /** * Logs a message if verbose debugging is enabled */ protected log(message: string): void; /** * Main method to run text recognition on an image with detected regions * @param image The original image buffer or image in Canvas * @param detection Array of bounding boxes from text detection * @param charactersDictionary Optional custom character dictionary * @returns Array of recognition results with text and bounding box, sorted in reading order */ run(image: ArrayBuffer | CoreCanvas, detection: Box[], charactersDictionary?: string[], strategy?: RecognitionStrategy): Promise; /** * Builds the strategy context from this service's state. */ private buildContext; /** * Filter out invalid boxes */ private filterValidBoxes; /** * Process a single text box (used by per-box strategy for debug output) */ private processBox; private recognizeTextViaContext; /** * Validates if a bounding box has valid dimensions */ private isValidBox; /** * Runs the ONNX inference session with the prepared tensor */ private runInference; }