Class cv::dnn::TextRecognitionModel#

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

Collaboration diagram for cv::dnn::TextRecognitionModel:

Public Member Functions#

Public Member Functions inherited from cv::dnn::Model

Return

Name

Description

Model()

Model(const Model &)

Model(const Net & network)

Create model from deep learning network.

Model(
    CV_WRAP_FILE_PATH const String & model,
    CV_WRAP_FILE_PATH const String & config = "" )

Create model from deep learning network represented in one of the supported formats. An order of model and config arguments does not matter.

Model(Model &&)

Model &

enableWinograd(bool useWinograd)

Impl *

getImpl()

Impl &

getImplRef()

Net &

getNetwork_()

Net &

getNetwork_()

operator Net &()

Model &

operator=(const Model &)

Model &

operator=(Model &&)

void

predict(
    InputArray frame,
    OutputArrayOfArrays outs )

Given the input frame, create input blob, run net and return the output blobs.

Model &

setInputCrop(bool crop)

Set flag crop for frame.

Model &

setInputMean(const Scalar & mean)

Set mean value for frame.

void

setInputParams(
    double scale = 1.0,
    const Size & size = Size(),
    const Scalar & mean = Scalar(),
    bool swapRB = false,
    bool crop = false )

Set preprocessing parameters for frame.

Model &

setInputScale(const Scalar & scale)

Set scalefactor value for frame.

Model &

setInputSize(const Size & size)

Set input size for frame.

Model &

setInputSize(
    int width,
    int height )

Model &

setInputSwapRB(bool swapRB)

Set flag swapRB for frame.

Model &

setOutputNames(const std::vector< String > & outNames)

Set output names for frame.

Model &

setPreferableBackend(dnn::Backend backendId)

Model &

setPreferableTarget(dnn::Target targetId)

Additional Inherited Members#

Protected Attributes inherited from cv::dnn::Model

Return

Name

Description

Ptr< Impl >

impl

Detailed Description#

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.

Examples
samples/dnn/text_detection.cpp.

Constructor & Destructor Documentation#

TextRecognitionModel()#

cv::dnn::TextRecognitionModel::TextRecognitionModel()

Python:

cv.dnn.TextRecognitionModel(network) -> <dnn_TextRecognitionModel object>
cv.dnn.TextRecognitionModel(model[, config]) -> <dnn_TextRecognitionModel object>

TextRecognitionModel()#

cv::dnn::TextRecognitionModel::TextRecognitionModel(const Net & network)

Python:

cv.dnn.TextRecognitionModel(network) -> <dnn_TextRecognitionModel object>
cv.dnn.TextRecognitionModel(model[, config]) -> <dnn_TextRecognitionModel object>

Create Text Recognition model from deep learning network Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method.

Parameters

  • networkNet object

TextRecognitionModel()#

cv::dnn::TextRecognitionModel::TextRecognitionModel(
CV_WRAP_FILE_PATH const std::string & model,
CV_WRAP_FILE_PATH const std::string & config = “” )

Python:

cv.dnn.TextRecognitionModel(network) -> <dnn_TextRecognitionModel object>
cv.dnn.TextRecognitionModel(model[, config]) -> <dnn_TextRecognitionModel object>

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

Parameters

  • model — Binary file contains trained weights

  • config — Text file contains network configuration

Here is the call graph for this function:

cv::dnn::TextRecognitionModel::TextRecognitionModel Node1 cv::dnn::TextRecognition Model::TextRecognitionModel Node2 cv::dnn::readNet Node1->Node2

cv::dnn::TextRecognitionModel::TextRecognitionModel Node1 cv::dnn::TextRecognition Model::TextRecognitionModel Node2 cv::dnn::readNet Node1->Node2

Member Function Documentation#

getDecodeType()#

const std::string & cv::dnn::TextRecognitionModel::getDecodeType()

Python:

cv.dnn.TextRecognitionModel.getDecodeType() -> retval

Get the decoding method.

Returns

the decoding method

getVocabulary()#

const std::vector< std::string > & cv::dnn::TextRecognitionModel::getVocabulary()

Python:

cv.dnn.TextRecognitionModel.getVocabulary() -> retval

Get the vocabulary for recognition.

Returns

vocabulary the associated vocabulary

recognize()#

std::string cv::dnn::TextRecognitionModel::recognize(InputArray frame)

Python:

cv.dnn.TextRecognitionModel.recognize(frame) -> retval
cv.dnn.TextRecognitionModel.recognize(frame, roiRects) -> results

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

Parameters

  • frame — The input image

Returns

The text recognition result

recognize()#

void cv::dnn::TextRecognitionModel::recognize(
InputArray frame,
InputArrayOfArrays roiRects,
std::vector< std::string > & results )

Python:

cv.dnn.TextRecognitionModel.recognize(frame) -> retval
cv.dnn.TextRecognitionModel.recognize(frame, roiRects) -> results

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

Parameters

  • 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 — A set of text recognition results.

setDecodeOptsCTCPrefixBeamSearch()#

TextRecognitionModel & cv::dnn::TextRecognitionModel::setDecodeOptsCTCPrefixBeamSearch(
int beamSize,
int vocPruneSize = 0 )

Python:

cv.dnn.TextRecognitionModel.setDecodeOptsCTCPrefixBeamSearch(beamSize[, vocPruneSize]) -> retval

Set the decoding method options for “CTC-prefix-beam-search” decode usage.

Parameters

  • 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.

setDecodeType()#

TextRecognitionModel & cv::dnn::TextRecognitionModel::setDecodeType(const std::string & decodeType)

Python:

cv.dnn.TextRecognitionModel.setDecodeType(decodeType) -> retval

Set the decoding method of translating the network output into string.

Parameters

  • 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

setVocabulary()#

TextRecognitionModel & cv::dnn::TextRecognitionModel::setVocabulary(const std::vector< std::string > & vocabulary)

Python:

cv.dnn.TextRecognitionModel.setVocabulary(vocabulary) -> retval

Set the vocabulary for recognition.

Parameters

  • vocabulary — the associated vocabulary of the network.

Source file#

The documentation for this class was generated from the following file: