| OpenCV 3.4.7 Open Source Computer Vision

Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cv::text::OCRBeamSearchDecoder Class Reference

OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm. More...

`#include <opencv2/text/ocr.hpp>`

Inheritance diagram for cv::text::OCRBeamSearchDecoder:

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

## Public Member Functions
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 Beam Search. More...
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
String | run (InputArray image, int min_confidence, int component_level=0)
String | run (InputArray image, InputArray mask, int min_confidence, int component_level=0)
Public Member Functions inherited from cv::text::BaseOCR
virtual | ~BaseOCR ()

## Static Public Member Functions
static Ptr< OCRBeamSearchDecoder > | create (const Ptr< OCRBeamSearchDecoder::ClassifierCallback > classifier, const std::string &vocabulary, InputArray transition_probabilities_table, InputArray emission_probabilities_table, decoder_mode mode=OCR_DECODER_VITERBI, int beam_size=500)
| Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder. More...
static Ptr< OCRBeamSearchDecoder > | create (const Ptr< OCRBeamSearchDecoder::ClassifierCallback > classifier, const String &vocabulary, InputArray transition_probabilities_table, InputArray emission_probabilities_table, int mode=OCR_DECODER_VITERBI, int beam_size=500)
static Ptr< OCRBeamSearchDecoder > | create (const String &filename, const String &vocabulary, InputArray transition_probabilities_table, InputArray emission_probabilities_table, int mode=OCR_DECODER_VITERBI, int beam_size=500)
| Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. More...

## Protected Attributes
int | beam_size
Ptr< OCRBeamSearchDecoder::ClassifierCallback > | classifier
Mat | emission_p
decoder_mode | mode
Mat | transition_p
std::string | vocabulary

## Detailed Description

OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm.

Note
  - (C++) An example on using OCRBeamSearchDecoder recognition combined with scene text detection can be found at the demo sample: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/word_recognition.cpp

## Member Function Documentation

## § create() [1/3]

static Ptr<OCRBeamSearchDecoder> cv::text::OCRBeamSearchDecoder::create | ( | const Ptr< OCRBeamSearchDecoder::ClassifierCallback > | classifier,
|  | const std::string & | vocabulary,
|  | InputArray | transition_probabilities_table,
|  | InputArray | emission_probabilities_table,
|  | decoder_mode | mode = `OCR_DECODER_VITERBI`,
|  | int | beam_size = `500`
| ) |  |
| static

Python:
| retval | = | cv.text.OCRBeamSearchDecoder_create( | classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )
| retval | = | cv.text.OCRBeamSearchDecoder_create( | filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )

Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder.

Parameters

  classifier | The character classifier with built in feature extractor.
  vocabulary | The language vocabulary (chars when ASCII English text). vocabulary.size() must be equal to the number of classes of the classifier.
  transition_probabilities_table | Table with transition probabilities between character pairs. cols == rows == vocabulary.size().
  emission_probabilities_table | Table with observation emission probabilities. cols == rows == vocabulary.size().
  mode | HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment (http://en.wikipedia.org/wiki/Viterbi_algorithm).
  beam_size | Size of the beam in Beam Search algorithm.

## § create() [2/3]

static Ptr<OCRBeamSearchDecoder> cv::text::OCRBeamSearchDecoder::create | ( | const Ptr< OCRBeamSearchDecoder::ClassifierCallback > | classifier,
|  | const String & | vocabulary,
|  | InputArray | transition_probabilities_table,
|  | InputArray | emission_probabilities_table,
|  | int | mode = `OCR_DECODER_VITERBI`,
|  | int | beam_size = `500`
| ) |  |
| static

Python:
| retval | = | cv.text.OCRBeamSearchDecoder_create( | classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )
| retval | = | cv.text.OCRBeamSearchDecoder_create( | filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )

## § create() [3/3]

static Ptr<OCRBeamSearchDecoder> cv::text::OCRBeamSearchDecoder::create | ( | const String & | filename,
|  | const String & | vocabulary,
|  | InputArray | transition_probabilities_table,
|  | InputArray | emission_probabilities_table,
|  | int | mode = `OCR_DECODER_VITERBI`,
|  | int | beam_size = `500`
| ) |  |
| static

Python:
| retval | = | cv.text.OCRBeamSearchDecoder_create( | classifier, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )
| retval | = | cv.text.OCRBeamSearchDecoder_create( | filename, vocabulary, transition_probabilities_table, emission_probabilities_table[, mode[, beam_size]] | )

Creates an instance of the OCRBeamSearchDecoder class. 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]

virtual void cv::text::OCRBeamSearchDecoder::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:
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, min_confidence[, component_level] | )
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, mask, min_confidence[, component_level] | )

Recognize text using Beam Search.

Takes 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

  image | Input binary image CV_8UC1 with a single text line (or word).
  output_text | Output text. Most likely character sequence found by the HMM decoder.
  component_rects | If provided the method will output a list of Rects for the individual text elements found (e.g. words).
  component_texts | If provided the method will output a list of text strings for the recognition of individual text elements found (e.g. words).
  component_confidences | If provided the method will output a list of confidence values for the recognition of individual text elements found (e.g. words).
  component_level | Only OCR_LEVEL_WORD is supported.

Implements cv::text::BaseOCR.

## § run() [2/4]

virtual void cv::text::OCRBeamSearchDecoder::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:
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, min_confidence[, component_level] | )
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, mask, min_confidence[, component_level] | )

Implements cv::text::BaseOCR.

## § run() [3/4]

String cv::text::OCRBeamSearchDecoder::run | ( | InputArray | image,
|  | int | min_confidence,
|  | int | component_level = `0`
| ) |  |

Python:
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, min_confidence[, component_level] | )
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, mask, min_confidence[, component_level] | )

## § run() [4/4]

String cv::text::OCRBeamSearchDecoder::run | ( | InputArray | image,
|  | InputArray | mask,
|  | int | min_confidence,
|  | int | component_level = `0`
| ) |  |

Python:
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, min_confidence[, component_level] | )
| retval | = | cv.text_OCRBeamSearchDecoder.run( | image, mask, min_confidence[, component_level] | )

## Member Data Documentation

## § beam_size

int cv::text::OCRBeamSearchDecoder::beam_size
| protected

## § classifier

Ptr<OCRBeamSearchDecoder::ClassifierCallback> cv::text::OCRBeamSearchDecoder::classifier
| protected

## § emission_p

Mat cv::text::OCRBeamSearchDecoder::emission_p
| protected

## § mode

decoder_mode cv::text::OCRBeamSearchDecoder::mode
| protected

## § transition_p

Mat cv::text::OCRBeamSearchDecoder::transition_p
| protected

## § vocabulary

std::string cv::text::OCRBeamSearchDecoder::vocabulary
| protected

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

- opencv2/text/ocr.hpp