OpenCV  3.4.14
Open Source Computer Vision
Classes | Enumerations | Functions
cv::text Namespace Reference

Classes

class  BaseOCR
 
class  ERFilter
 Base class for 1st and 2nd stages of Neumann and Matas scene text detection algorithm [159]. : More...
 
struct  ERStat
 The ERStat structure represents a class-specific Extremal Region (ER). More...
 
class  OCRBeamSearchDecoder
 OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm. More...
 
class  OCRHMMDecoder
 OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models. More...
 
class  OCRHolisticWordRecognizer
 OCRHolisticWordRecognizer class provides the functionallity of segmented wordspotting. Given a predefined vocabulary , a DictNet is employed to select the most probable word given an input image. More...
 
class  OCRTesseract
 OCRTesseract class provides an interface with the tesseract-ocr API (v3.02.02) in C++. More...
 
class  TextDetector
 An abstract class providing interface for text detection algorithms. More...
 
class  TextDetectorCNN
 TextDetectorCNN class provides the functionallity of text bounding box detection. This class is representing to find bounding boxes of text words given an input image. This class uses OpenCV dnn module to load pre-trained model described in [129]. The original repository with the modified SSD Caffe version: https://github.com/MhLiao/TextBoxes. Model can be downloaded from DropBox. Modified .prototxt file with the model description can be found in opencv_contrib/modules/text/samples/textbox.prototxt. More...
 

Enumerations

enum  {
  ERFILTER_NM_RGBLGrad,
  ERFILTER_NM_IHSGrad
}
 computeNMChannels operation modes More...
 
enum  {
  OCR_LEVEL_WORD,
  OCR_LEVEL_TEXTLINE
}
 
enum  classifier_type {
  OCR_KNN_CLASSIFIER = 0,
  OCR_CNN_CLASSIFIER = 1
}
 
enum  decoder_mode { OCR_DECODER_VITERBI = 0 }
 
enum  erGrouping_Modes {
  ERGROUPING_ORIENTATION_HORIZ,
  ERGROUPING_ORIENTATION_ANY
}
 text::erGrouping operation modes More...
 
enum  ocr_engine_mode {
  OEM_TESSERACT_ONLY,
  OEM_CUBE_ONLY,
  OEM_TESSERACT_CUBE_COMBINED,
  OEM_DEFAULT
}
 Tesseract.OcrEngineMode Enumeration. More...
 
enum  page_seg_mode {
  PSM_OSD_ONLY,
  PSM_AUTO_OSD,
  PSM_AUTO_ONLY,
  PSM_AUTO,
  PSM_SINGLE_COLUMN,
  PSM_SINGLE_BLOCK_VERT_TEXT,
  PSM_SINGLE_BLOCK,
  PSM_SINGLE_LINE,
  PSM_SINGLE_WORD,
  PSM_CIRCLE_WORD,
  PSM_SINGLE_CHAR
}
 Tesseract.PageSegMode Enumeration. More...
 

Functions

void computeNMChannels (InputArray _src, OutputArrayOfArrays _channels, int _mode=ERFILTER_NM_RGBLGrad)
 Compute the different channels to be processed independently in the N&M algorithm [159]. More...
 
Ptr< ERFiltercreateERFilterNM1 (const Ptr< ERFilter::Callback > &cb, int thresholdDelta=1, float minArea=(float) 0.00025, float maxArea=(float) 0.13, float minProbability=(float) 0.4, bool nonMaxSuppression=true, float minProbabilityDiff=(float) 0.1)
 Create an Extremal Region Filter for the 1st stage classifier of N&M algorithm [159]. More...
 
Ptr< ERFiltercreateERFilterNM1 (const String &filename, int thresholdDelta=1, float minArea=(float) 0.00025, float maxArea=(float) 0.13, float minProbability=(float) 0.4, bool nonMaxSuppression=true, float minProbabilityDiff=(float) 0.1)
 Reads an Extremal Region Filter for the 1st stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM1.xml. More...
 
Ptr< ERFiltercreateERFilterNM2 (const Ptr< ERFilter::Callback > &cb, float minProbability=(float) 0.3)
 Create an Extremal Region Filter for the 2nd stage classifier of N&M algorithm [159]. More...
 
Ptr< ERFiltercreateERFilterNM2 (const String &filename, float minProbability=(float) 0.3)
 Reads an Extremal Region Filter for the 2nd stage classifier of N&M algorithm from the provided path e.g. /path/to/cpp/trained_classifierNM2.xml. More...
 
void createOCRHMMTransitionsTable (std::string &vocabulary, std::vector< std::string > &lexicon, OutputArray transition_probabilities_table)
 Utility function to create a tailored language model transitions table from a given list of words (lexicon). More...
 
Mat createOCRHMMTransitionsTable (const String &vocabulary, std::vector< cv::String > &lexicon)
 
void detectRegions (InputArray image, const Ptr< ERFilter > &er_filter1, const Ptr< ERFilter > &er_filter2, std::vector< std::vector< Point > > &regions)
 
void detectRegions (InputArray image, const Ptr< ERFilter > &er_filter1, const Ptr< ERFilter > &er_filter2, std::vector< Rect > &groups_rects, int method=ERGROUPING_ORIENTATION_HORIZ, const String &filename=String(), float minProbability=(float) 0.5)
 Extracts text regions from image. More...
 
void erGrouping (InputArray img, InputArrayOfArrays channels, std::vector< std::vector< ERStat > > &regions, std::vector< std::vector< Vec2i > > &groups, std::vector< Rect > &groups_rects, int method=ERGROUPING_ORIENTATION_HORIZ, const std::string &filename=std::string(), float minProbablity=0.5)
 Find groups of Extremal Regions that are organized as text blocks. More...
 
void erGrouping (InputArray image, InputArray channel, std::vector< std::vector< Point > > regions, std::vector< Rect > &groups_rects, int method=ERGROUPING_ORIENTATION_HORIZ, const String &filename=String(), float minProbablity=(float) 0.5)
 
Ptr< ERFilter::CallbackloadClassifierNM1 (const String &filename)
 Allow to implicitly load the default classifier when creating an ERFilter object. More...
 
Ptr< ERFilter::CallbackloadClassifierNM2 (const String &filename)
 Allow to implicitly load the default classifier when creating an ERFilter object. More...
 
Ptr< OCRBeamSearchDecoder::ClassifierCallbackloadOCRBeamSearchClassifierCNN (const String &filename)
 Allow to implicitly load the default character classifier when creating an OCRBeamSearchDecoder object. More...
 
Ptr< OCRHMMDecoder::ClassifierCallbackloadOCRHMMClassifier (const String &filename, int classifier)
 Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object. More...
 
Ptr< OCRHMMDecoder::ClassifierCallbackloadOCRHMMClassifierCNN (const String &filename)
 Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object. More...
 
Ptr< OCRHMMDecoder::ClassifierCallbackloadOCRHMMClassifierNM (const String &filename)
 Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object. More...
 
void MSERsToERStats (InputArray image, std::vector< std::vector< Point > > &contours, std::vector< std::vector< ERStat > > &regions)
 Converts MSER contours (vector<Point>) to ERStat regions. More...
 

Function Documentation

◆ createOCRHMMTransitionsTable() [1/2]

void cv::text::createOCRHMMTransitionsTable ( std::string &  vocabulary,
std::vector< std::string > &  lexicon,
OutputArray  transition_probabilities_table 
)
Python:
retval=cv.text.createOCRHMMTransitionsTable(vocabulary, lexicon)

Utility function to create a tailored language model transitions table from a given list of words (lexicon).

Parameters
vocabularyThe language vocabulary (chars when ASCII English text).
lexiconThe list of words that are expected to be found in a particular image.
transition_probabilities_tableOutput table with transition probabilities between character pairs. cols == rows == vocabulary.size().

The function calculate frequency statistics of character pairs from the given lexicon and fills the output transition_probabilities_table with them. The transition_probabilities_table can be used as input in the OCRHMMDecoder::create() and OCRBeamSearchDecoder::create() methods.

Note

◆ createOCRHMMTransitionsTable() [2/2]

Mat cv::text::createOCRHMMTransitionsTable ( const String vocabulary,
std::vector< cv::String > &  lexicon 
)
Python:
retval=cv.text.createOCRHMMTransitionsTable(vocabulary, lexicon)

◆ loadOCRBeamSearchClassifierCNN()

Ptr<OCRBeamSearchDecoder::ClassifierCallback> cv::text::loadOCRBeamSearchClassifierCNN ( const String filename)
Python:
retval=cv.text.loadOCRBeamSearchClassifierCNN(filename)

Allow to implicitly load the default character classifier when creating an OCRBeamSearchDecoder object.

Parameters
filenameThe XML or YAML file with the classifier model (e.g. OCRBeamSearch_CNN_model_data.xml.gz)

The CNN default classifier is based in the scene text recognition method proposed by Adam Coates & Andrew NG in [Coates11a]. The character classifier consists in a Single Layer Convolutional Neural Network and a linear classifier. It is applied to the input image in a sliding window fashion, providing a set of recognitions at each window location.