Class TextRecognitionModel
- Namespace
- OpenCvSharp.Dnn
- Assembly
- OpenCvSharp.dll
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.
public class TextRecognitionModel : Model, IDisposable
- Inheritance
-
TextRecognitionModel
- Implements
- Inherited Members
Constructors
TextRecognitionModel(Net)
Create model from deep learning network.
public TextRecognitionModel(Net network)
Parameters
networkNetNet object.
TextRecognitionModel(string, string?)
Create text recognition model from network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
public TextRecognitionModel(string model, string? config = null)
Parameters
modelstringBinary file contains trained weights.
configstringText file contains network configuration.
Methods
GetDecodeType()
Get the decoding method.
public string GetDecodeType()
Returns
- string
the decoding method
GetVocabulary()
Get the vocabulary for recognition.
public string?[] GetVocabulary()
Returns
- string[]
vocabulary the associated vocabulary of the network.
Recognize(InputArray)
Given the @p input frame, create input blob, run net and return recognition result.
public string Recognize(InputArray frame)
Parameters
frameInputArrayThe input image.
Returns
- string
The text recognition result.
Recognize(InputArray, IEnumerable<Rect>)
Given the @p input frame, create input blob, run net and return recognition result for each ROI.
public string?[] Recognize(InputArray frame, IEnumerable<Rect> roiRects)
Parameters
frameInputArrayThe input image.
roiRectsIEnumerable<Rect>List of text detection regions of interest. ROIs are cropped as the network inputs.
Returns
- string[]
A set of text recognition results, one per ROI.
SetDecodeOptsCTCPrefixBeamSearch(int, int)
Set the decoding method options for "CTC-prefix-beam-search" decode usage.
public void SetDecodeOptsCTCPrefixBeamSearch(int beamSize, int vocPruneSize = 0)
Parameters
beamSizeintBeam size for search
vocPruneSizeintParameter to optimize big vocabulary search, only take top @p vocPruneSize tokens in each search step, @p vocPruneSize <= 0 stands for disable this prune.
SetDecodeType(string)
Set the decoding method of translating the network output into string.
public void SetDecodeType(string decodeType)
Parameters
decodeTypestringThe 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
SetVocabulary(IEnumerable<string>)
Set the vocabulary for recognition.
public void SetVocabulary(IEnumerable<string> vocabulary)
Parameters
vocabularyIEnumerable<string>the associated vocabulary of the network.