import * as ort from "onnxruntime-node";
import { Canvas } from "ppu-ocv";
import type { Box, DebuggingOptions, RecognitionOptions } from "../interface";
export interface RecognitionResult {
    text: string;
    box: Box;
    confidence: number;
}
/**
 * Service for detecting and recognizing text in images
 */
export declare class RecognitionService {
    private readonly options;
    private readonly debugging;
    private readonly session;
    private readonly toolkit;
    private static readonly BLANK_INDEX;
    private static readonly UNK_TOKEN;
    private static readonly MIN_CROP_WIDTH;
    constructor(session: ort.InferenceSession, options?: Partial<RecognitionOptions>, debugging?: Partial<DebuggingOptions>);
    /**
     * Logs a message if verbose debugging is enabled
     */
    private log;
    /**
     * 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
     * @returns Array of recognition results with text and bounding box, sorted in reading order
     */
    run(image: ArrayBuffer | Canvas, detection: Box[]): Promise<RecognitionResult[]>;
    /**
     * Filter out invalid boxes
     */
    private filterValidBoxes;
    /**
     * Process all valid boxes in parallel using Promise.all
     */
    private processBoxesInParallel;
    /**
     * Process a single text box
     */
    private processBox;
    /**
     * Sort recognition results by reading order (top to bottom, left to right)
     */
    private sortResultsByReadingOrder;
    /**
     * Validates if a bounding box has valid dimensions
     */
    private isValidBox;
    /**
     * Crops a region from the source canvas based on bounding box
     */
    private cropRegion;
    /**
     * Saves a debug image of the cropped region
     */
    private saveDebugCrop;
    /**
     * Logs details about the processing of a text region
     */
    private logProcessingDetails;
    /**
     * Recognizes text in a cropped canvas region
     */
    private recognizeText;
    /**
     * Preprocesses a cropped image for the recognition model
     */
    private preprocessImage;
    /**
     * Creates a normalized image tensor from the preprocessed canvas
     */
    private createImageTensor;
    /**
     * Runs the ONNX inference session with the prepared tensor
     */
    private runInference;
    /**
     * Decodes the results from the model output tensor
     */
    private decodeResults;
    /**
     * Performs greedy decoding on CTC model output logits
     */
    private ctcGreedyDecode;
    /**
     * Appends the appropriate character to the decoded text
     */
    private appendCharacterToText;
    /**
     * Finds the class with maximum probability for a given timestep
     */
    private findMaxProbabilityClass;
    /**
     * Checks if the predicted class index is valid for the character dictionary
     */
    private isValidDictionaryIndex;
}
