OCRBeamSearchDecoder

Objective-C

@interface OCRBeamSearchDecoder : BaseOCR

Swift

class OCRBeamSearchDecoder : BaseOCR

OCRBeamSearchDecoder class provides an interface for OCR using Beam Search algorithm.

@note - (C++) An example on using OCRBeamSearchDecoder recognition combined with scene text detection can be found at the demo sample: https://github.com/opencv/opencv_contrib/blob/master/modules/text/samples/word_recognition.cpp

Member of Text

Methods

  • Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder.

    Declaration

    Objective-C

    + (nonnull OCRBeamSearchDecoder
           *)create:(nonnull OCRBeamSearchDecoderClassifierCallback *)classifier
                            vocabulary:(nonnull NSString *)vocabulary
        transition_probabilities_table:(nonnull Mat *)transition_probabilities_table
          emission_probabilities_table:(nonnull Mat *)emission_probabilities_table
                                  mode:(decoder_mode)mode
                             beam_size:(int)beam_size;

    Swift

    class func create(classifier: OCRBeamSearchDecoderClassifierCallback, vocabulary: String, transition_probabilities_table: Mat, emission_probabilities_table: Mat, mode: decoder_mode, beam_size: Int32) -> OCRBeamSearchDecoder

    Parameters

    classifier

    The character classifier with built in feature extractor.

    vocabulary

    The language vocabulary (chars when ASCII English text). vocabulary.size() must be equal to the number of classes of the classifier.

    transition_probabilities_table

    Table with transition probabilities between character pairs. cols == rows == vocabulary.size().

    emission_probabilities_table

    Table with observation emission probabilities. cols == rows == vocabulary.size().

    mode

    HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment (http://en.wikipedia.org/wiki/Viterbi_algorithm).

    beam_size

    Size of the beam in Beam Search algorithm.

  • Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder.

    Declaration

    Objective-C

    + (nonnull OCRBeamSearchDecoder
           *)create:(nonnull OCRBeamSearchDecoderClassifierCallback *)classifier
                            vocabulary:(nonnull NSString *)vocabulary
        transition_probabilities_table:(nonnull Mat *)transition_probabilities_table
          emission_probabilities_table:(nonnull Mat *)emission_probabilities_table
                                  mode:(decoder_mode)mode;

    Swift

    class func create(classifier: OCRBeamSearchDecoderClassifierCallback, vocabulary: String, transition_probabilities_table: Mat, emission_probabilities_table: Mat, mode: decoder_mode) -> OCRBeamSearchDecoder

    Parameters

    classifier

    The character classifier with built in feature extractor.

    vocabulary

    The language vocabulary (chars when ASCII English text). vocabulary.size() must be equal to the number of classes of the classifier.

    transition_probabilities_table

    Table with transition probabilities between character pairs. cols == rows == vocabulary.size().

    emission_probabilities_table

    Table with observation emission probabilities. cols == rows == vocabulary.size().

    mode

    HMM Decoding algorithm. Only OCR_DECODER_VITERBI is available for the moment (http://en.wikipedia.org/wiki/Viterbi_algorithm).

  • Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path.

    Declaration

    Objective-C

    + (nonnull OCRBeamSearchDecoder *)
                        createFromFile:(nonnull NSString *)filename
                            vocabulary:(nonnull NSString *)vocabulary
        transition_probabilities_table:(nonnull Mat *)transition_probabilities_table
          emission_probabilities_table:(nonnull Mat *)emission_probabilities_table
                                  mode:(decoder_mode)mode
                             beam_size:(int)beam_size;

    Swift

    class func create(filename: String, vocabulary: String, transition_probabilities_table: Mat, emission_probabilities_table: Mat, mode: decoder_mode, beam_size: Int32) -> OCRBeamSearchDecoder
  • Creates an instance of the OCRBeamSearchDecoder class. Initializes HMMDecoder from the specified path.

    Declaration

    Objective-C

    + (nonnull OCRBeamSearchDecoder *)
                        createFromFile:(nonnull NSString *)filename
                            vocabulary:(nonnull NSString *)vocabulary
        transition_probabilities_table:(nonnull Mat *)transition_probabilities_table
          emission_probabilities_table:(nonnull Mat *)emission_probabilities_table
                                  mode:(decoder_mode)mode;

    Swift

    class func create(filename: String, vocabulary: String, transition_probabilities_table: Mat, emission_probabilities_table: Mat, mode: decoder_mode) -> OCRBeamSearchDecoder
  • Declaration

    Objective-C

    - (NSString*)run:(Mat*)image mask:(Mat*)mask min_confidence:(int)min_confidence component_level:(int)component_level NS_SWIFT_NAME(run(image:mask:min_confidence:component_level:));

    Swift

    func run(image: Mat, mask: Mat, min_confidence: Int32, component_level: Int32) -> String
  • Declaration

    Objective-C

    - (NSString*)run:(Mat*)image mask:(Mat*)mask min_confidence:(int)min_confidence NS_SWIFT_NAME(run(image:mask:min_confidence:));

    Swift

    func run(image: Mat, mask: Mat, min_confidence: Int32) -> String
  • Recognize text using Beam Search.

     Takes image on input and returns recognized text in the output_text parameter. Optionally
     provides also the Rects for individual text elements found (e.g. words), and the list of those
     text elements with their confidence values.
    

    Declaration

    Objective-C

    - (nonnull NSString *)run:(nonnull Mat *)image
               min_confidence:(int)min_confidence
              component_level:(int)component_level;

    Swift

    func run(image: Mat, min_confidence: Int32, component_level: Int32) -> String

    Parameters

    image

    Input binary image CV_8UC1 with a single text line (or word).

    text elements found (e.g. words).

    recognition of individual text elements found (e.g. words).

    for the recognition of individual text elements found (e.g. words).

    component_level

    Only OCR_LEVEL_WORD is supported.

  • Recognize text using Beam Search.

     Takes image on input and returns recognized text in the output_text parameter. Optionally
     provides also the Rects for individual text elements found (e.g. words), and the list of those
     text elements with their confidence values.
    

    Declaration

    Objective-C

    - (nonnull NSString *)run:(nonnull Mat *)image
               min_confidence:(int)min_confidence;

    Swift

    func run(image: Mat, min_confidence: Int32) -> String

    Parameters

    image

    Input binary image CV_8UC1 with a single text line (or word).

    text elements found (e.g. words).

    recognition of individual text elements found (e.g. words).

    for the recognition of individual text elements found (e.g. words).