React Native OCR - v0.11.0
    Preparing search index...

    Type Alias TextBoxExtractor

    A detector's box-extraction strategy. Plug a new detector architecture into the OCR pipeline by supplying an object of this type (a built-in below, or your own). outputShapes and extract MUST be worklets.

    type TextBoxExtractor = {
        detectOutputSpec: (
            dim: (symbol: string) => SymbolicDim,
        ) => ParamSpec<SymbolicDim>[];
        extract: (
            outputs: readonly Tensor[],
            inputSize: { height: number; width: number },
            charLevel: boolean,
        ) => Quad[];
        inputAlignment?: number;
        outputShapes: (inputSize: { height: number; width: number }) => number[][];
        supportsCharLevel?: boolean;
    }
    Index
    detectOutputSpec: (
        dim: (symbol: string) => SymbolicDim,
    ) => ParamSpec<SymbolicDim>[]

    The allowed spec of the detect outputs this strategy decodes, used to validate the model at load. Dimensions that track the detector input size must be built with the supplied dim factory: the pipeline passes schema.DynamicDim when validating a size-varying detector and schema.StaticDim when validating a fixed-size one, so one declaration covers both.

    Type Declaration

      • (dim: (symbol: string) => SymbolicDim): ParamSpec<SymbolicDim>[]
      • Parameters

        • dim: (symbol: string) => SymbolicDim

          Symbol factory for every input-size-dependent dimension.

        Returns ParamSpec<SymbolicDim>[]

        One param spec per detect output, in order.

    extract: (
        outputs: readonly Tensor[],
        inputSize: { height: number; width: number },
        charLevel: boolean,
    ) => Quad[]

    Turns the model's detect output tensors into oriented quads in detector-input pixel space.

    Type Declaration

      • (
            outputs: readonly Tensor[],
            inputSize: { height: number; width: number },
            charLevel: boolean,
        ): Quad[]
      • Parameters

        • outputs: readonly Tensor[]

          The model's detect output tensors, in order.

        • inputSize: { height: number; width: number }

          The detector input size the image was letterboxed to.

        • charLevel: boolean

          Emit one box per glyph instead of grouped lines; strategies without a char-level mode ignore it.

        Returns Quad[]

        Oriented quads (TL, TR, BR, BL) in detector-input pixel space.

    inputAlignment?: number

    The detector input dims (W and H) must be a multiple of this; the pipeline snaps the letterbox size up to it before allocating, so outputShapes never receives a size it must reject. Default 1 (no alignment). CRAFT needs 2 (its heatmap is half-resolution).

    outputShapes: (inputSize: { height: number; width: number }) => number[][]

    The float32 output tensor shapes the detect method produces for a given detector input size, so the caller can pre-allocate them. One shape per detect output, in order.

    Type Declaration

      • (inputSize: { height: number; width: number }): number[][]
      • Parameters

        • inputSize: { height: number; width: number }

          The detector input size the image was letterboxed to.

        Returns number[][]

        One shape per detect output tensor.

    supportsCharLevel?: boolean

    Whether extract(.., charLevel = true) yields per-glyph boxes. When false the stacked-text (vertical) pass skips its char-level re-detection split and reads those boxes horizontally instead. Default false.