From 52f5f056ccbf765f49bbdbddbfc97f49f002db26 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 13 Nov 2020 13:42:51 +0000 Subject: [PATCH] text: drop ambiguous call, fix bindings --- modules/text/include/opencv2/text/ocr.hpp | 28 ++++++++------------- modules/text/src/ocr_beamsearch_decoder.cpp | 12 +-------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/modules/text/include/opencv2/text/ocr.hpp b/modules/text/include/opencv2/text/ocr.hpp index 0137c37a8b6..6cb23fa4ee4 100644 --- a/modules/text/include/opencv2/text/ocr.hpp +++ b/modules/text/include/opencv2/text/ocr.hpp @@ -474,40 +474,34 @@ class CV_EXPORTS_W OCRBeamSearchDecoder : public BaseOCR @param beam_size Size of the beam in Beam Search algorithm. */ - static Ptr create(const Ptr classifier,// The character classifier with built in feature extractor + static CV_WRAP + Ptr create(const Ptr classifier,// The character classifier with built in feature extractor const std::string& vocabulary, // The language vocabulary (chars when ASCII English text) // size() must be equal to the number of classes InputArray transition_probabilities_table, // Table with transition probabilities between character pairs // cols == rows == vocabulary.size() InputArray emission_probabilities_table, // Table with observation emission probabilities // cols == rows == vocabulary.size() - decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) - int beam_size = 500); // Size of the beam in Beam Search algorithm - - CV_WRAP static Ptr create(const Ptr classifier, // The character classifier with built in feature extractor - const String& vocabulary, // The language vocabulary (chars when ASCII English text) - // size() must be equal to the number of classes - InputArray transition_probabilities_table, // Table with transition probabilities between character pairs - // cols == rows == vocabulary.size() - InputArray emission_probabilities_table, // Table with observation emission probabilities - // cols == rows == vocabulary.size() - int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) - int beam_size = 500); // Size of the beam in Beam Search algorithm + text::decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) + int beam_size = 500 // Size of the beam in Beam Search algorithm + ); /** @brief Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. @overload */ - CV_WRAP static Ptr create(const String& filename, // The character classifier file - const String& vocabulary, // The language vocabulary (chars when ASCII English text) + static //CV_WRAP FIXIT bug in handling of Java overloads + Ptr create(const String& filename, // The character classifier file + const String& vocabulary, // The language vocabulary (chars when ASCII English text) // size() must be equal to the number of classes InputArray transition_probabilities_table, // Table with transition probabilities between character pairs // cols == rows == vocabulary.size() InputArray emission_probabilities_table, // Table with observation emission probabilities // cols == rows == vocabulary.size() - int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) - int beam_size = 500); + text::decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) + int beam_size = 500 // Size of the beam in Beam Search algorithm + ); protected: Ptr classifier; diff --git a/modules/text/src/ocr_beamsearch_decoder.cpp b/modules/text/src/ocr_beamsearch_decoder.cpp index 4b0c43c0fac..6f34056ed90 100644 --- a/modules/text/src/ocr_beamsearch_decoder.cpp +++ b/modules/text/src/ocr_beamsearch_decoder.cpp @@ -499,21 +499,11 @@ Ptr OCRBeamSearchDecoder::create( Ptr(_classifier, _vocabulary, transition_p, emission_p, _mode, _beam_size); } -Ptr OCRBeamSearchDecoder::create(Ptr _classifier, - const String& _vocabulary, - InputArray transition_p, - InputArray emission_p, - int _mode, - int _beam_size) -{ - return makePtr(_classifier, _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size); -} - Ptr OCRBeamSearchDecoder::create(const String& _filename, const String& _vocabulary, InputArray transition_p, InputArray emission_p, - int _mode, + decoder_mode _mode, int _beam_size) { return makePtr(loadOCRBeamSearchClassifierCNN(_filename), _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size);