44#ifndef __OPENCV_TEXT_OCR_HPP__
45#define __OPENCV_TEXT_OCR_HPP__
47#include <opencv2/core.hpp>
74 PSM_SINGLE_BLOCK_VERT_TEXT,
87 OEM_TESSERACT_CUBE_COMBINED,
96 virtual void run(
Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL,
97 std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
98 int component_level=0) = 0;
99 virtual void run(
Mat& image,
Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL,
100 std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
101 int component_level=0) = 0;
135 virtual void run(
Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL,
136 std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
137 int component_level=0) CV_OVERRIDE;
139 virtual
void run(
Mat& image,
Mat& mask, std::
string& output_text, std::vector<
Rect>* component_rects=NULL,
140 std::vector<std::
string>* component_texts=NULL, std::vector<
float>* component_confidences=NULL,
141 int component_level=0) CV_OVERRIDE;
144 CV_WRAP String run(InputArray image,
int min_confidence,
int component_level=0);
146 CV_WRAP String run(InputArray image, InputArray mask,
int min_confidence,
int component_level=0);
148 CV_WRAP virtual
void setWhiteList(const String& char_whitelist) = 0;
165 CV_WRAP static
Ptr<
OCRTesseract> create(const
char* datapath=NULL, const
char* language=NULL,
166 const
char* char_whitelist=NULL,
int oem=OEM_DEFAULT,
int psmode=PSM_AUTO);
174 OCR_DECODER_VITERBI = 0
180 OCR_KNN_CLASSIFIER = 0,
181 OCR_CNN_CLASSIFIER = 1
216 virtual void eval( InputArray image, std::vector<int>& out_class, std::vector<double>& out_confidence);
241 virtual void run(
Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL,
242 std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
243 int component_level=0) CV_OVERRIDE;
268 virtual
void run(
Mat& image,
Mat& mask, std::
string& output_text, std::vector<
Rect>* component_rects=NULL,
269 std::vector<std::
string>* component_texts=NULL, std::vector<
float>* component_confidences=NULL,
270 int component_level=0) CV_OVERRIDE;
273 CV_WRAP String run(InputArray image,
int min_confidence,
int component_level=0);
275 CV_WRAP String run(InputArray image, InputArray mask,
int min_confidence,
int component_level=0);
295 const String& vocabulary,
297 InputArray transition_probabilities_table,
299 InputArray emission_probabilities_table,
301 int mode = OCR_DECODER_VITERBI);
309 const String& vocabulary,
311 InputArray transition_probabilities_table,
313 InputArray emission_probabilities_table,
315 int mode = OCR_DECODER_VITERBI,
317 int classifier = OCR_KNN_CLASSIFIER);
321 std::
string vocabulary;
379CV_EXPORTS
void createOCRHMMTransitionsTable(std::
string& vocabulary, std::vector<std::
string>& lexicon,
OutputArray transition_probabilities_table);
381CV_EXPORTS_W
Mat createOCRHMMTransitionsTable(const String& vocabulary, std::vector<
cv::String>& lexicon);
418 virtual void eval( InputArray image, std::vector< std::vector<double> >& recognition_probabilities, std::vector<int>& oversegmentation );
420 int getWindowSize() {
return 0;}
421 int getStepSize() {
return 0;}
446 virtual void run(
Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL,
447 std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
448 int component_level=0) CV_OVERRIDE;
450 virtual
void run(
Mat& image,
Mat& mask, std::
string& output_text, std::vector<
Rect>* component_rects=NULL,
451 std::vector<std::
string>* component_texts=NULL, std::vector<
float>* component_confidences=NULL,
452 int component_level=0) CV_OVERRIDE;
455 CV_WRAP String run(InputArray image,
int min_confidence,
int component_level=0);
457 CV_WRAP String run(InputArray image, InputArray mask,
int min_confidence,
int component_level=0);
479 const std::
string& vocabulary,
481 InputArray transition_probabilities_table,
483 InputArray emission_probabilities_table,
485 text::decoder_mode mode = OCR_DECODER_VITERBI,
496 const String& vocabulary,
498 InputArray transition_probabilities_table,
500 InputArray emission_probabilities_table,
502 text::decoder_mode mode = OCR_DECODER_VITERBI,
508 std::
string vocabulary;
539 virtual void run(
Mat& image,
540 std::string& output_text,
541 std::vector<Rect>* component_rects = NULL,
542 std::vector<std::string>* component_texts = NULL,
543 std::vector<float>* component_confidences = NULL,
544 int component_level = OCR_LEVEL_WORD) CV_OVERRIDE = 0;
571 std::string& output_text,
572 std::vector<Rect>* component_rects = NULL,
573 std::vector<std::string>* component_texts = NULL,
574 std::vector<float>* component_confidences = NULL,
575 int component_level = OCR_LEVEL_WORD) CV_OVERRIDE = 0;
580 const std::string &weightsFilename,
581 const std::string &wordsFilename);
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition: mat.hpp:295
n-dimensional dense array class
Definition: mat.hpp:802
Template class for 2D rectangles
Definition: core/types.hpp:421
Callback with the character classifier is made a class.
Definition: ocr.hpp:407
virtual void eval(InputArray image, std::vector< std::vector< double > > &recognition_probabilities, std::vector< int > &oversegmentation)
The character classifier must return a (ranked list of) class(es) id('s)
OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm.
Definition: ocr.hpp:394
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.
Callback with the character classifier is made a class.
Definition: ocr.hpp:205
virtual void eval(InputArray image, std::vector< int > &out_class, std::vector< double > &out_confidence)
The character classifier must return a (ranked list of) class(es) id('s)
OCRHMMDecoder class provides an interface for OCR using Hidden Markov Models.
Definition: ocr.hpp:192
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.
OCRHolisticWordRecognizer class provides the functionallity of segmented wordspotting....
Definition: ocr.hpp:537
static Ptr< OCRHolisticWordRecognizer > create(const std::string &archFilename, const std::string &weightsFilename, const std::string &wordsFilename)
Creates an instance of the OCRHolisticWordRecognizer class.
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=OCR_LEVEL_WORD) CV_OVERRIDE=0
Recognize text using a segmentation based word-spotting/classifier cnn.
OCRTesseract class provides an interface with the tesseract-ocr API (v3.02.02) in C++.
Definition: ocr.hpp:117
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 the tesseract-ocr API.
page_seg_mode
Tesseract.PageSegMode Enumeration
Definition: ocr.hpp:68
CV_EXPORTS_W Ptr< OCRHMMDecoder::ClassifierCallback > loadOCRHMMClassifierNM(const String &filename)
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
ocr_engine_mode
Tesseract.OcrEngineMode Enumeration
Definition: ocr.hpp:84
CV_EXPORTS_W Ptr< OCRHMMDecoder::ClassifierCallback > loadOCRHMMClassifierCNN(const String &filename)
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
CV_EXPORTS_W Ptr< OCRHMMDecoder::ClassifierCallback > loadOCRHMMClassifier(const String &filename, int classifier)
Allow to implicitly load the default character classifier when creating an OCRHMMDecoder object.
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74