Skip to content

dnn_TextRecognitionModel

Deep neural networksclassOpenCV 5.0.0
import { dnn_TextRecognitionModel } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSdnn_TextRecognitionModel
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits dnn_Model.

This class represents high-level API for text recognition networks.

TextRecognitionModel allows to set params for preprocessing input image. TextRecognitionModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return recognition result. For TextRecognitionModel, CRNN-CTC is supported.

Constructors and members

static new

Create text recognition model from network represented in one of the supported formats Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method

new(model: EmbindString, config: EmbindString): dnn_TextRecognitionModel;
2 available overloads
new(network: dnn_Net): dnn_TextRecognitionModel;
new(model: EmbindString, config: EmbindString): dnn_TextRecognitionModel;
network

Net object

model

Binary file contains trained weights

config

Text file contains network configuration

Returns

The dnn_TextRecognitionModel result.

static from1

Create an owned dnn_TextRecognitionModel instance with the supplied configuration.

This class represents high-level API for text recognition networks.

from1(_0: EmbindString): dnn_TextRecognitionModel | null;
_0

0 argument (EmbindString).

Returns

The dnn_TextRecognitionModel | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

setDecodeType

Set the decoding method of translating the network output into string

setDecodeType(decodeType: EmbindString): dnn_TextRecognitionModel;
decodeType

The decoding method of translating the network output into string, currently supported type:

  • "CTC-greedy" greedy decoding for the output of CTC-based methods
  • "CTC-prefix-beam-search" Prefix beam search decoding for the output of CTC-based methods
Returns

The dnn_TextRecognitionModel result.

getDecodeType

Get the decoding method

getDecodeType(): string;
Returns

the decoding method

setDecodeOptsCTCPrefixBeamSearch

Set the decoding method options for "CTC-prefix-beam-search" decode usage

setDecodeOptsCTCPrefixBeamSearch(beamSize: number, vocPruneSize: number): dnn_TextRecognitionModel;
2 available overloads
setDecodeOptsCTCPrefixBeamSearch(beamSize: number): dnn_TextRecognitionModel;
setDecodeOptsCTCPrefixBeamSearch(beamSize: number, vocPruneSize: number): dnn_TextRecognitionModel;
beamSize

Beam size for search

vocPruneSize

Parameter to optimize big vocabulary search, only take top vocPruneSize tokens in each search step, vocPruneSize <= 0 stands for disable this prune.

Returns

The dnn_TextRecognitionModel result.

setVocabulary

Set the vocabulary for recognition.

setVocabulary(vocabulary: StringVector): dnn_TextRecognitionModel;
vocabulary

the associated vocabulary of the network.

Returns

The dnn_TextRecognitionModel result.

getVocabulary

Get the vocabulary for recognition.

getVocabulary(): StringVector;
Returns

vocabulary the associated vocabulary Release returned native handles with using or delete(), including handles nested in results.

recognize

Given the input frame, create input blob, run net and return recognition result

recognize(frame: Mat): string;
frame

The input image

Returns

The text recognition result

recognize1

Given the input frame, create input blob, run net and return recognition result

recognize1(frame: Mat, roiRects: MatVector, results: StringVector): void;
frame

The input image

roiRects

List of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs

results

Output destination, filled by the native operation. A set of text recognition results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.