Merge pull request #2748 from alalek:text_drop_ambiguous_api

pull/2737/head
Alexander Alekhin 5 years ago
commit ae4d5d3d0c
  1. 26
      modules/text/include/opencv2/text/ocr.hpp
  2. 12
      modules/text/src/ocr_beamsearch_decoder.cpp

@ -474,40 +474,34 @@ public:
@param beam_size Size of the beam in Beam Search algorithm. @param beam_size Size of the beam in Beam Search algorithm.
*/ */
static Ptr<OCRBeamSearchDecoder> create(const Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier,// The character classifier with built in feature extractor static CV_WRAP
Ptr<OCRBeamSearchDecoder> create(const Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier,// The character classifier with built in feature extractor
const std::string& vocabulary, // The language vocabulary (chars when ASCII English text) const std::string& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes // size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
// cols == rows == vocabulary.size() // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities InputArray emission_probabilities_table, // Table with observation emission probabilities
// cols == rows == vocabulary.size() // cols == rows == vocabulary.size()
decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) 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 int beam_size = 500 // Size of the beam in Beam Search algorithm
);
CV_WRAP static Ptr<OCRBeamSearchDecoder> create(const Ptr<OCRBeamSearchDecoder::ClassifierCallback> 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
/** @brief Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path. /** @brief Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path.
@overload @overload
*/ */
CV_WRAP static Ptr<OCRBeamSearchDecoder> create(const String& filename, // The character classifier file static //CV_WRAP FIXIT bug in handling of Java overloads
Ptr<OCRBeamSearchDecoder> create(const String& filename, // The character classifier file
const String& vocabulary, // The language vocabulary (chars when ASCII English text) const String& vocabulary, // The language vocabulary (chars when ASCII English text)
// size() must be equal to the number of classes // size() must be equal to the number of classes
InputArray transition_probabilities_table, // Table with transition probabilities between character pairs InputArray transition_probabilities_table, // Table with transition probabilities between character pairs
// cols == rows == vocabulary.size() // cols == rows == vocabulary.size()
InputArray emission_probabilities_table, // Table with observation emission probabilities InputArray emission_probabilities_table, // Table with observation emission probabilities
// cols == rows == vocabulary.size() // cols == rows == vocabulary.size()
int mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment) text::decoder_mode mode = OCR_DECODER_VITERBI, // HMM Decoding algorithm (only Viterbi for the moment)
int beam_size = 500); int beam_size = 500 // Size of the beam in Beam Search algorithm
);
protected: protected:
Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier; Ptr<OCRBeamSearchDecoder::ClassifierCallback> classifier;

@ -499,21 +499,11 @@ Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create( Ptr<OCRBeamSearchDecoder
return makePtr<OCRBeamSearchDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, _mode, _beam_size); return makePtr<OCRBeamSearchDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, _mode, _beam_size);
} }
Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(Ptr<OCRBeamSearchDecoder::ClassifierCallback> _classifier,
const String& _vocabulary,
InputArray transition_p,
InputArray emission_p,
int _mode,
int _beam_size)
{
return makePtr<OCRBeamSearchDecoderImpl>(_classifier, _vocabulary, transition_p, emission_p, (decoder_mode)_mode, _beam_size);
}
Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(const String& _filename, Ptr<OCRBeamSearchDecoder> OCRBeamSearchDecoder::create(const String& _filename,
const String& _vocabulary, const String& _vocabulary,
InputArray transition_p, InputArray transition_p,
InputArray emission_p, InputArray emission_p,
int _mode, decoder_mode _mode,
int _beam_size) int _beam_size)
{ {
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);

Loading…
Cancel
Save