text: apply CV_OVERRIDE/CV_FINAL

pull/1588/head
Alexander Alekhin 7 years ago
parent 5683521417
commit e4c8510e3a
  1. 16
      modules/text/include/opencv2/text/ocr.hpp
  2. 2
      modules/text/include/opencv2/text/textDetector.hpp
  3. 38
      modules/text/src/erfilter.cpp
  4. 14
      modules/text/src/ocr_beamsearch_decoder.cpp
  5. 14
      modules/text/src/ocr_hmm_decoder.cpp
  6. 6
      modules/text/src/ocr_holistic.cpp
  7. 10
      modules/text/src/ocr_tesseract.cpp
  8. 2
      modules/text/src/text_detectorCNN.cpp

@ -134,11 +134,11 @@ public:
*/ */
virtual void run(Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
virtual void run(Mat& image, Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
// aliases for scripting // aliases for scripting
CV_WRAP String run(InputArray image, int min_confidence, int component_level=0); CV_WRAP String run(InputArray image, int min_confidence, int component_level=0);
@ -240,7 +240,7 @@ public:
*/ */
virtual void run(Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
/** @brief Recognize text using HMM. /** @brief Recognize text using HMM.
@ -267,7 +267,7 @@ public:
*/ */
virtual void run(Mat& image, Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
// aliases for scripting // aliases for scripting
CV_WRAP String run(InputArray image, int min_confidence, int component_level=0); CV_WRAP String run(InputArray image, int min_confidence, int component_level=0);
@ -453,11 +453,11 @@ public:
*/ */
virtual void run(Mat& image, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
virtual void run(Mat& image, Mat& mask, std::string& output_text, std::vector<Rect>* component_rects=NULL, 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, std::vector<std::string>* component_texts=NULL, std::vector<float>* component_confidences=NULL,
int component_level=0); int component_level=0) CV_OVERRIDE;
// aliases for scripting // aliases for scripting
CV_WRAP String run(InputArray image, int min_confidence, int component_level=0); CV_WRAP String run(InputArray image, int min_confidence, int component_level=0);
@ -555,7 +555,7 @@ public:
std::vector<Rect>* component_rects = NULL, std::vector<Rect>* component_rects = NULL,
std::vector<std::string>* component_texts = NULL, std::vector<std::string>* component_texts = NULL,
std::vector<float>* component_confidences = NULL, std::vector<float>* component_confidences = NULL,
int component_level = OCR_LEVEL_WORD) = 0; int component_level = OCR_LEVEL_WORD) CV_OVERRIDE = 0;
/** @brief Recognize text using a segmentation based word-spotting/classifier cnn. /** @brief Recognize text using a segmentation based word-spotting/classifier cnn.
@ -586,7 +586,7 @@ public:
std::vector<Rect>* component_rects = NULL, std::vector<Rect>* component_rects = NULL,
std::vector<std::string>* component_texts = NULL, std::vector<std::string>* component_texts = NULL,
std::vector<float>* component_confidences = NULL, std::vector<float>* component_confidences = NULL,
int component_level = OCR_LEVEL_WORD) = 0; int component_level = OCR_LEVEL_WORD) CV_OVERRIDE = 0;
/** @brief Creates an instance of the OCRHolisticWordRecognizer class. /** @brief Creates an instance of the OCRHolisticWordRecognizer class.
*/ */

@ -48,7 +48,7 @@ public:
@param Bbox a vector of Rect that will store the detected word bounding box @param Bbox a vector of Rect that will store the detected word bounding box
@param confidence a vector of float that will be updated with the confidence the classifier has for the selected bounding box @param confidence a vector of float that will be updated with the confidence the classifier has for the selected bounding box
*/ */
CV_WRAP virtual void detect(InputArray inputImage, CV_OUT std::vector<Rect>& Bbox, CV_OUT std::vector<float>& confidence) = 0; CV_WRAP virtual void detect(InputArray inputImage, CV_OUT std::vector<Rect>& Bbox, CV_OUT std::vector<float>& confidence) CV_OVERRIDE = 0;
/** @brief Creates an instance of the TextDetectorCNN class using the provided parameters. /** @brief Creates an instance of the TextDetectorCNN class using the provided parameters.

@ -114,7 +114,7 @@ public:
//Constructor //Constructor
ERFilterNM(); ERFilterNM();
//Destructor //Destructor
~ERFilterNM() {} ~ERFilterNM() CV_OVERRIDE {}
float minProbability; float minProbability;
bool nonMaxSuppression; bool nonMaxSuppression;
@ -122,7 +122,7 @@ public:
// the key method. Takes image on input, vector of ERStat is output for the first stage, // the key method. Takes image on input, vector of ERStat is output for the first stage,
// input/output - for the second one. // input/output - for the second one.
void run( InputArray image, vector<ERStat>& regions ); void run( InputArray image, vector<ERStat>& regions ) CV_OVERRIDE;
protected: protected:
int thresholdDelta; int thresholdDelta;
@ -138,14 +138,14 @@ protected:
public: public:
// set/get methods to set the algorithm properties, // set/get methods to set the algorithm properties,
void setCallback(const Ptr<ERFilter::Callback>& cb); void setCallback(const Ptr<ERFilter::Callback>& cb) CV_OVERRIDE;
void setThresholdDelta(int thresholdDelta); void setThresholdDelta(int thresholdDelta) CV_OVERRIDE;
void setMinArea(float minArea); void setMinArea(float minArea) CV_OVERRIDE;
void setMaxArea(float maxArea); void setMaxArea(float maxArea) CV_OVERRIDE;
void setMinProbability(float minProbability); void setMinProbability(float minProbability) CV_OVERRIDE;
void setMinProbabilityDiff(float minProbabilityDiff); void setMinProbabilityDiff(float minProbabilityDiff) CV_OVERRIDE;
void setNonMaxSuppression(bool nonMaxSuppression); void setNonMaxSuppression(bool nonMaxSuppression) CV_OVERRIDE;
int getNumRejected(); int getNumRejected() CV_OVERRIDE;
private: private:
// pointer to the input/output regions vector // pointer to the input/output regions vector
@ -171,32 +171,32 @@ private:
// default 1st stage classifier // default 1st stage classifier
class CV_EXPORTS ERClassifierNM1 : public ERFilter::Callback class CV_EXPORTS ERClassifierNM1 CV_FINAL : public ERFilter::Callback
{ {
public: public:
//Constructor //Constructor
ERClassifierNM1(const string& filename); ERClassifierNM1(const string& filename);
// Destructor // Destructor
~ERClassifierNM1() {} ~ERClassifierNM1() CV_OVERRIDE {}
// The classifier must return probability measure for the region. // The classifier must return probability measure for the region.
double eval(const ERStat& stat); double eval(const ERStat& stat) CV_OVERRIDE;
private: private:
Ptr<Boost> boost; Ptr<Boost> boost;
}; };
// default 2nd stage classifier // default 2nd stage classifier
class CV_EXPORTS ERClassifierNM2 : public ERFilter::Callback class CV_EXPORTS ERClassifierNM2 CV_FINAL : public ERFilter::Callback
{ {
public: public:
//constructor //constructor
ERClassifierNM2(const string& filename); ERClassifierNM2(const string& filename);
// Destructor // Destructor
~ERClassifierNM2() {} ~ERClassifierNM2() CV_OVERRIDE {}
// The classifier must return probability measure for the region. // The classifier must return probability measure for the region.
double eval(const ERStat& stat); double eval(const ERStat& stat) CV_OVERRIDE;
private: private:
Ptr<Boost> boost; Ptr<Boost> boost;
@ -1178,16 +1178,16 @@ Ptr<ERFilter::Callback> loadClassifierNM2(const String& filename)
} }
// dummy classifier // dummy classifier
class ERDummyClassifier : public ERFilter::Callback class ERDummyClassifier CV_FINAL : public ERFilter::Callback
{ {
public: public:
//Constructor //Constructor
ERDummyClassifier() {} ERDummyClassifier() {}
// Destructor // Destructor
~ERDummyClassifier() {} ~ERDummyClassifier() CV_OVERRIDE {}
// The classifier must return probability measure for the region. // The classifier must return probability measure for the region.
double eval(const ERStat& s) {if (s.area ==0) return (double)0.0; return (double)1.0;} double eval(const ERStat& s) CV_OVERRIDE {if (s.area ==0) return (double)0.0; return (double)1.0;}
}; };
/* Create a dummy classifier that accepts all regions */ /* Create a dummy classifier that accepts all regions */

@ -155,7 +155,7 @@ bool beam_sort_function ( beamSearch_node a, beamSearch_node b )
} }
class OCRBeamSearchDecoderImpl : public OCRBeamSearchDecoder class OCRBeamSearchDecoderImpl CV_FINAL : public OCRBeamSearchDecoder
{ {
public: public:
//Default constructor //Default constructor
@ -186,7 +186,7 @@ public:
} }
} }
~OCRBeamSearchDecoderImpl() ~OCRBeamSearchDecoderImpl() CV_OVERRIDE
{ {
} }
@ -196,7 +196,7 @@ public:
vector<Rect>* component_rects, vector<Rect>* component_rects,
vector<string>* component_texts, vector<string>* component_texts,
vector<float>* component_confidences, vector<float>* component_confidences,
int component_level) int component_level) CV_OVERRIDE
{ {
CV_Assert(mask.type() == CV_8UC1); CV_Assert(mask.type() == CV_8UC1);
//nothing to do with a mask here //nothing to do with a mask here
@ -209,7 +209,7 @@ public:
vector<Rect>* component_rects, vector<Rect>* component_rects,
vector<string>* component_texts, vector<string>* component_texts,
vector<float>* component_confidences, vector<float>* component_confidences,
int component_level) int component_level) CV_OVERRIDE
{ {
CV_Assert( (src.type() == CV_8UC1) || (src.type() == CV_8UC3) ); CV_Assert( (src.type() == CV_8UC1) || (src.type() == CV_8UC3) );
@ -519,15 +519,15 @@ Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(const String& _filename,
return makePtr<OCRBeamSearchDecoderImpl>(loadOCRBeamSearchClassifierCNN(_filename), _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size); return makePtr<OCRBeamSearchDecoderImpl>(loadOCRBeamSearchClassifierCNN(_filename), _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size);
} }
class OCRBeamSearchClassifierCNN : public OCRBeamSearchDecoder::ClassifierCallback class OCRBeamSearchClassifierCNN CV_FINAL : public OCRBeamSearchDecoder::ClassifierCallback
{ {
public: public:
//constructor //constructor
OCRBeamSearchClassifierCNN(const std::string& filename); OCRBeamSearchClassifierCNN(const std::string& filename);
// Destructor // Destructor
~OCRBeamSearchClassifierCNN() {} ~OCRBeamSearchClassifierCNN() CV_OVERRIDE {}
void eval( InputArray src, vector< vector<double> >& recognition_probabilities, vector<int>& oversegmentation ); void eval( InputArray src, vector< vector<double> >& recognition_probabilities, vector<int>& oversegmentation ) CV_OVERRIDE;
int getWindowSize() {return window_size;} int getWindowSize() {return window_size;}
int getStepSize() {return step_size;} int getStepSize() {return step_size;}

@ -158,7 +158,7 @@ public:
mode = _mode; mode = _mode;
} }
~OCRHMMDecoderImpl() ~OCRHMMDecoderImpl() CV_OVERRIDE
{ {
} }
@ -167,7 +167,7 @@ public:
vector<Rect>* component_rects, vector<Rect>* component_rects,
vector<string>* component_texts, vector<string>* component_texts,
vector<float>* component_confidences, vector<float>* component_confidences,
int component_level) int component_level) CV_OVERRIDE
{ {
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) ); CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
@ -413,7 +413,7 @@ public:
vector<Rect>* component_rects, vector<Rect>* component_rects,
vector<string>* component_texts, vector<string>* component_texts,
vector<float>* component_confidences, vector<float>* component_confidences,
int component_level) int component_level) CV_OVERRIDE
{ {
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) ); CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
@ -694,15 +694,15 @@ Ptr<OCRHMMDecoder> OCRHMMDecoder::create( const String& _filename,
return makePtr<OCRHMMDecoderImpl>(loadOCRHMMClassifier(_filename, _classifier), _vocabulary, transition_p, emission_p, (decoder_mode)_mode); return makePtr<OCRHMMDecoderImpl>(loadOCRHMMClassifier(_filename, _classifier), _vocabulary, transition_p, emission_p, (decoder_mode)_mode);
} }
class OCRHMMClassifierKNN : public OCRHMMDecoder::ClassifierCallback class OCRHMMClassifierKNN CV_FINAL : public OCRHMMDecoder::ClassifierCallback
{ {
public: public:
//constructor //constructor
OCRHMMClassifierKNN(const std::string& filename); OCRHMMClassifierKNN(const std::string& filename);
// Destructor // Destructor
~OCRHMMClassifierKNN() {} ~OCRHMMClassifierKNN() CV_OVERRIDE {}
void eval( InputArray mask, vector<int>& out_class, vector<double>& out_confidence ); void eval( InputArray mask, vector<int>& out_class, vector<double>& out_confidence ) CV_OVERRIDE;
private: private:
Ptr<KNearest> knn; Ptr<KNearest> knn;
}; };
@ -956,7 +956,7 @@ public:
// Destructor // Destructor
~OCRHMMClassifierCNN() {} ~OCRHMMClassifierCNN() {}
void eval( InputArray image, vector<int>& out_class, vector<double>& out_confidence ); void eval( InputArray image, vector<int>& out_class, vector<double>& out_confidence ) CV_OVERRIDE;
protected: protected:
void normalizeAndZCA(Mat& patches); void normalizeAndZCA(Mat& patches);

@ -13,7 +13,7 @@ using namespace std;
namespace cv { namespace text { namespace cv { namespace text {
class OCRHolisticWordRecognizerImpl : public OCRHolisticWordRecognizer class OCRHolisticWordRecognizerImpl CV_FINAL : public OCRHolisticWordRecognizer
{ {
private: private:
dnn::Net net; dnn::Net net;
@ -34,7 +34,7 @@ public:
CV_Assert(getClassCount() == words.size()); CV_Assert(getClassCount() == words.size());
} }
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) 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
{ {
CV_Assert(component_level==OCR_LEVEL_WORD); //Componnents not applicable for word spotting CV_Assert(component_level==OCR_LEVEL_WORD); //Componnents not applicable for word spotting
double confidence; double confidence;
@ -53,7 +53,7 @@ public:
} }
} }
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) 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
{ {
//Mask is ignored because the CNN operates on a full image //Mask is ignored because the CNN operates on a full image
CV_Assert(mask.cols == image.cols && mask.rows == image.rows); CV_Assert(mask.cols == image.cols && mask.rows == image.rows);

@ -127,7 +127,7 @@ CV_WRAP String OCRTesseract::run(InputArray image, InputArray mask, int min_conf
} }
class OCRTesseractImpl : public OCRTesseract class OCRTesseractImpl CV_FINAL : public OCRTesseract
{ {
private: private:
#ifdef HAVE_TESSERACT #ifdef HAVE_TESSERACT
@ -172,7 +172,7 @@ public:
#endif #endif
} }
~OCRTesseractImpl() ~OCRTesseractImpl() CV_OVERRIDE
{ {
#ifdef HAVE_TESSERACT #ifdef HAVE_TESSERACT
tess.End(); tess.End();
@ -181,7 +181,7 @@ public:
void run(Mat& image, string& output, vector<Rect>* component_rects=NULL, void run(Mat& image, string& output, vector<Rect>* component_rects=NULL,
vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL, vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL,
int component_level=0) int component_level=0) CV_OVERRIDE
{ {
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) ); CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
@ -249,7 +249,7 @@ public:
void run(Mat& image, Mat& mask, string& output, vector<Rect>* component_rects=NULL, void run(Mat& image, Mat& mask, string& output, vector<Rect>* component_rects=NULL,
vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL, vector<string>* component_texts=NULL, vector<float>* component_confidences=NULL,
int component_level=0) int component_level=0) CV_OVERRIDE
{ {
CV_Assert( mask.type() == CV_8UC1 ); CV_Assert( mask.type() == CV_8UC1 );
CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) ); CV_Assert( (image.type() == CV_8UC1) || (image.type() == CV_8UC3) );
@ -257,7 +257,7 @@ public:
run( mask, output, component_rects, component_texts, component_confidences, component_level); run( mask, output, component_rects, component_texts, component_confidences, component_level);
} }
void setWhiteList(const String& char_whitelist) void setWhiteList(const String& char_whitelist) CV_OVERRIDE
{ {
#ifdef HAVE_TESSERACT #ifdef HAVE_TESSERACT
tess.SetVariable("tessedit_char_whitelist", char_whitelist.c_str()); tess.SetVariable("tessedit_char_whitelist", char_whitelist.c_str());

@ -60,7 +60,7 @@ public:
inputChannelCount_ = 3; inputChannelCount_ = 3;
} }
void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence) void detect(InputArray inputImage_, std::vector<Rect>& Bbox, std::vector<float>& confidence) CV_OVERRIDE
{ {
CV_Assert(inputImage_.channels() == inputChannelCount_); CV_Assert(inputImage_.channels() == inputChannelCount_);
Mat inputImage = inputImage_.getMat(); Mat inputImage = inputImage_.getMat();

Loading…
Cancel
Save