OpenCV  4.5.3
Open Source Computer Vision
Public Member Functions | List of all members
cv::dnn::TextRecognitionModel Class Reference

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

#include <opencv2/dnn/dnn.hpp>

Inheritance diagram for cv::dnn::TextRecognitionModel:
cv::dnn::Model

Public Member Functions

 TextRecognitionModel ()
 
 TextRecognitionModel (const Net &network)
 Create Text Recognition model from deep learning network Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method. More...
 
 TextRecognitionModel (const std::string &model, const std::string &config="")
 Create text recognition model from network represented in one of the supported formats Call setDecodeType() and setVocabulary() after constructor to initialize the decoding method. More...
 
const std::string & getDecodeType () const
 Get the decoding method. More...
 
const std::vector< std::string > & getVocabulary () const
 Get the vocabulary for recognition. More...
 
std::string recognize (InputArray frame) const
 Given the input frame, create input blob, run net and return recognition result. More...
 
void recognize (InputArray frame, InputArrayOfArrays roiRects, std::vector< std::string > &results) const
 Given the input frame, create input blob, run net and return recognition result. More...
 
TextRecognitionModelsetDecodeType (const std::string &decodeType)
 Set the decoding method of translating the network output into string. More...
 
TextRecognitionModelsetVocabulary (const std::vector< std::string > &vocabulary)
 Set the vocabulary for recognition. More...
 
- Public Member Functions inherited from cv::dnn::Model
 Model ()
 
 Model (const Model &)=default
 
 Model (Model &&)=default
 
 Model (const String &model, 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. More...
 
 Model (const Net &network)
 Create model from deep learning network. More...
 
Impl * getImpl () const
 
Impl & getImplRef () const
 
NetgetNetwork_ () const
 
NetgetNetwork_ ()
 
 operator Net & () const
 
Modeloperator= (const Model &)=default
 
Modeloperator= (Model &&)=default
 
void predict (InputArray frame, OutputArrayOfArrays outs) const
 Given the input frame, create input blob, run net and return the output blobs. More...
 
ModelsetInputCrop (bool crop)
 Set flag crop for frame. More...
 
ModelsetInputMean (const Scalar &mean)
 Set mean value for frame. More...
 
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. More...
 
ModelsetInputScale (double scale)
 Set scalefactor value for frame. More...
 
ModelsetInputSize (const Size &size)
 Set input size for frame. More...
 
ModelsetInputSize (int width, int height)
 
ModelsetInputSwapRB (bool swapRB)
 Set flag swapRB for frame. More...
 
ModelsetPreferableBackend (dnn::Backend backendId)
 
ModelsetPreferableTarget (dnn::Target targetId)
 

Additional Inherited Members

- Protected Attributes inherited from cv::dnn::Model
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() [1/3]

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

◆ TextRecognitionModel() [2/3]

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
[in]networkNet object

◆ TextRecognitionModel() [3/3]

cv::dnn::TextRecognitionModel::TextRecognitionModel ( const std::string &  model,
const std::string &  config = "" 
)
inline
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
[in]modelBinary file contains trained weights
[in]configText file contains network configuration

Member Function Documentation

◆ getDecodeType()

const std::string& cv::dnn::TextRecognitionModel::getDecodeType ( ) const
Python:
cv.dnn_TextRecognitionModel.getDecodeType() -> retval

Get the decoding method.

Returns
the decoding method

◆ getVocabulary()

const std::vector<std::string>& cv::dnn::TextRecognitionModel::getVocabulary ( ) const
Python:
cv.dnn_TextRecognitionModel.getVocabulary() -> retval

Get the vocabulary for recognition.

Returns
vocabulary the associated vocabulary

◆ recognize() [1/2]

std::string cv::dnn::TextRecognitionModel::recognize ( InputArray  frame) const
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
[in]frameThe input image
Returns
The text recognition result

◆ recognize() [2/2]

void cv::dnn::TextRecognitionModel::recognize ( InputArray  frame,
InputArrayOfArrays  roiRects,
std::vector< std::string > &  results 
) const
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
[in]frameThe input image
[in]roiRectsList of text detection regions of interest (cv::Rect, CV_32SC4). ROIs is be cropped as the network inputs
[out]resultsA set of text recognition results.

◆ 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
[in]decodeTypeThe decoding method of translating the network output into string: {'CTC-greedy': greedy 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
[in]vocabularythe associated vocabulary of the network.

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