OpenCV  4.9.0-dev
Open Source Computer Vision
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cv::text::OCRHMMDecoder Class Reference

OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models. More...

#include <opencv2/text/ocr.hpp>

Inheritance diagram for cv::text::OCRHMMDecoder:
Collaboration diagram for cv::text::OCRHMMDecoder:

Classes

class  ClassifierCallback
 Callback with the character classifier is made a class. More...
 

Public Member Functions

String run (InputArray image, InputArray mask, int min_confidence, int component_level=0)
 
String run (InputArray image, int min_confidence, int component_level=0)
 
virtual void run (Mat &image, Mat &mask, std::string &output_text, std::vector< Rect > *component_rects=NULL, std::vector< std::string > *component_texts=NULL, std::vector< float > *component_confidences=NULL, int component_level=0) CV_OVERRIDE
 Recognize text using HMM.
 
virtual void run (Mat &image, std::string &output_text, std::vector< Rect > *component_rects=NULL, std::vector< std::string > *component_texts=NULL, std::vector< float > *component_confidences=NULL, int component_level=0) CV_OVERRIDE
 Recognize text using HMM.
 
- Public Member Functions inherited from cv::text::BaseOCR
virtual ~BaseOCR ()
 

Static Public Member Functions

static Ptr< OCRHMMDecodercreate (const Ptr< OCRHMMDecoder::ClassifierCallback > classifier, const String &vocabulary, InputArray transition_probabilities_table, InputArray emission_probabilities_table, int mode=OCR_DECODER_VITERBI)
 Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder.
 
static Ptr< OCRHMMDecodercreate (const String &filename, const String &vocabulary, InputArray transition_probabilities_table, InputArray emission_probabilities_table, int mode=OCR_DECODER_VITERBI, int classifier=OCR_KNN_CLASSIFIER)
 Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path.
 

Protected Attributes

Ptr< OCRHMMDecoder::ClassifierCallbackclassifier
 
Mat emission_p
 
decoder_mode mode
 
Mat transition_p
 
std::string vocabulary
 

Detailed Description

OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models.

Note

Member Function Documentation

◆ create() [1/2]

static Ptr< OCRHMMDecoder > cv::text::OCRHMMDecoder::create ( const Ptr< OCRHMMDecoder::ClassifierCallback classifier,
const String vocabulary,
InputArray  transition_probabilities_table,
InputArray  emission_probabilities_table,
int  mode = OCR_DECODER_VITERBI 
)
static
Python:
cv.text.OCRHMMDecoder.create(classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode]) -> retval
cv.text.OCRHMMDecoder.create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, classifier]]) -> retval
cv.text.OCRHMMDecoder_create(classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode]) -> retval
cv.text.OCRHMMDecoder_create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, classifier]]) -> retval

Creates an instance of the OCRHMMDecoder class. Initializes HMMDecoder.

Parameters
classifierThe character classifier with built in feature extractor.
vocabularyThe language vocabulary (chars when ascii english text). vocabulary.size() must be equal to the number of classes of the classifier.
transition_probabilities_tableTable with transition probabilities between character pairs. cols == rows == vocabulary.size().
emission_probabilities_tableTable with observation emission probabilities. cols == rows == vocabulary.size().
modeHMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment (http://en.wikipedia.org/wiki/Viterbi_algorithm).

◆ create() [2/2]

static Ptr< OCRHMMDecoder > cv::text::OCRHMMDecoder::create ( const String filename,
const String vocabulary,
InputArray  transition_probabilities_table,
InputArray  emission_probabilities_table,
int  mode = OCR_DECODER_VITERBI,
int  classifier = OCR_KNN_CLASSIFIER 
)
static
Python:
cv.text.OCRHMMDecoder.create(classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode]) -> retval
cv.text.OCRHMMDecoder.create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, classifier]]) -> retval
cv.text.OCRHMMDecoder_create(classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode]) -> retval
cv.text.OCRHMMDecoder_create(filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, classifier]]) -> retval

Creates an instance of the OCRHMMDecoder class. Loads and initializes HMMDecoder from the specified path.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ run() [1/4]

String cv::text::OCRHMMDecoder::run ( InputArray  image,
InputArray  mask,
int  min_confidence,
int  component_level = 0 
)
Python:
cv.text.OCRHMMDecoder.run(image, min_confidence[, component_level]) -> retval
cv.text.OCRHMMDecoder.run(image, mask, min_confidence[, component_level]) -> retval

◆ run() [2/4]

String cv::text::OCRHMMDecoder::run ( InputArray  image,
int  min_confidence,
int  component_level = 0 
)
Python:
cv.text.OCRHMMDecoder.run(image, min_confidence[, component_level]) -> retval
cv.text.OCRHMMDecoder.run(image, mask, min_confidence[, component_level]) -> retval

◆ run() [3/4]

virtual void cv::text::OCRHMMDecoder::run ( Mat image,
Mat mask,
std::string &  output_text,
std::vector< Rect > *  component_rects = NULL,
std::vector< std::string > *  component_texts = NULL,
std::vector< float > *  component_confidences = NULL,
int  component_level = 0 
)
virtual
Python:
cv.text.OCRHMMDecoder.run(image, min_confidence[, component_level]) -> retval
cv.text.OCRHMMDecoder.run(image, mask, min_confidence[, component_level]) -> retval

Recognize text using HMM.

Takes an image and a mask (where each connected component corresponds to a segmented character) on input and returns recognized text in the output_text parameter. Optionally provides also the Rects for individual text elements found (e.g. words), and the list of those text elements with their confidence values.

Parameters
imageInput image CV_8UC1 or CV_8UC3 with a single text line (or word).
maskInput binary image CV_8UC1 same size as input image. Each connected component in mask corresponds to a segmented character in the input image.
output_textOutput text. Most likely character sequence found by the HMM decoder.
component_rectsIf provided the method will output a list of Rects for the individual text elements found (e.g. words).
component_textsIf provided the method will output a list of text strings for the recognition of individual text elements found (e.g. words).
component_confidencesIf provided the method will output a list of confidence values for the recognition of individual text elements found (e.g. words).
component_levelOnly OCR_LEVEL_WORD is supported.

Implements cv::text::BaseOCR.

◆ run() [4/4]

virtual void cv::text::OCRHMMDecoder::run ( Mat image,
std::string &  output_text,
std::vector< Rect > *  component_rects = NULL,
std::vector< std::string > *  component_texts = NULL,
std::vector< float > *  component_confidences = NULL,
int  component_level = 0 
)
virtual
Python:
cv.text.OCRHMMDecoder.run(image, min_confidence[, component_level]) -> retval
cv.text.OCRHMMDecoder.run(image, mask, min_confidence[, component_level]) -> retval

Recognize text using HMM.

Takes binary image on input and returns recognized text in the output_text parameter. Optionally provides also the Rects for individual text elements found (e.g. words), and the list of those text elements with their confidence values.

Parameters
imageInput binary image CV_8UC1 with a single text line (or word).
output_textOutput text. Most likely character sequence found by the HMM decoder.
component_rectsIf provided the method will output a list of Rects for the individual text elements found (e.g. words).
component_textsIf provided the method will output a list of text strings for the recognition of individual text elements found (e.g. words).
component_confidencesIf provided the method will output a list of confidence values for the recognition of individual text elements found (e.g. words).
component_levelOnly OCR_LEVEL_WORD is supported.

Implements cv::text::BaseOCR.

Member Data Documentation

◆ classifier

Ptr<OCRHMMDecoder::ClassifierCallback> cv::text::OCRHMMDecoder::classifier
protected

◆ emission_p

Mat cv::text::OCRHMMDecoder::emission_p
protected

◆ mode

decoder_mode cv::text::OCRHMMDecoder::mode
protected

◆ transition_p

Mat cv::text::OCRHMMDecoder::transition_p
protected

◆ vocabulary

std::string cv::text::OCRHMMDecoder::vocabulary
protected

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