Class BlinkOCREngineOptions

java.lang.Object
com.microblink.photopay.entities.ocrengine.AbstractOCREngineOptions<BlinkOCREngineOptions>
com.microblink.photopay.entities.ocrengine.legacy.BlinkOCREngineOptions
All Implemented Interfaces:
android.os.Parcelable

public final class BlinkOCREngineOptions extends AbstractOCREngineOptions<BlinkOCREngineOptions>
Options used in legacy BlinkOCR engine.
  • Field Details

    • CREATOR

      @NonNull public static final android.os.Parcelable.Creator<BlinkOCREngineOptions> CREATOR
      Parcelable creator.
  • Constructor Details

    • BlinkOCREngineOptions

      public BlinkOCREngineOptions()
      Default constructor.
    • BlinkOCREngineOptions

      public BlinkOCREngineOptions(long nativeContext, @Nullable Object keep)
      Constructor from native object.
      Parameters:
      nativeContext - Native engine options object.
      keep - Owner of the native engine options object.
  • Method Details

    • clone

      @NonNull public BlinkOCREngineOptions clone()
      Creates a copy of BlinkOCREngineOptions object.
      Overrides:
      clone in class Object
      Returns:
      a copy
    • getMinimumLineHeight

      public final int getMinimumLineHeight()
      Returns the minimum height of the line of text given in pixels. All lines smaller than this value are ignored. Line height is defined as height of largest character in line.
      Returns:
      minimum height of the line
    • setMinimumLineHeight

      @NonNull public final BlinkOCREngineOptions setMinimumLineHeight(@IntRange(from=0L) int minimumLineHeight)
      Sets the minimum height of the line of text given in pixels. All chars smaller than this value will be ignored.
      Parameters:
      minimumLineHeight - minimum height of the line
      Returns:
      this object, to support chaining of operations.
    • getMaximumLineHeight

      public final int getMaximumLineHeight()
      Returns the maximum height of the line of text given in pixels. All chars larger than this value are ignored.
      Returns:
      maximum height of the line
    • setMaximumLineHeight

      @NonNull public final BlinkOCREngineOptions setMaximumLineHeight(@IntRange(from=0L) int maximumLineHeight)
      Sets the maximum height of the line of text given in pixels. All chars larger than this value will be ignored.
      Parameters:
      maximumLineHeight - maximum height of the line
      Returns:
      this object, to support chaining of operations.
    • getMinimumCharHeight

      public final int getMinimumCharHeight()
      Returns the minimum height of char that can be classified. All chars smaller than this value are ignored.
      Returns:
      minimum height of the char
    • setMinimumCharHeight

      @NonNull public final BlinkOCREngineOptions setMinimumCharHeight(@IntRange(from=0L) int minimumCharHeight)
      Sets the minimum height of the char that can be classified. All chars smaller than this value are ignored. Unlike setMinimumLineHeight(int), this value refers to individual chars, while setMinimumLineHeight(int) refers to line height, which equals to height of largest char in line.
      Parameters:
      minimumCharHeight - minimum height of the char
      Returns:
      this object, to support chaining of operations
    • setImageProcessingEnabled

      @NonNull public BlinkOCREngineOptions setImageProcessingEnabled(boolean imageProcessingEnabled)
      Specifies if the image processing is performed on image By default it's set to true. Disable it only if you perform your own image processing.
      Parameters:
      imageProcessingEnabled - whether or not image processing should be performed on image
      Returns:
      this object, to support chaining of operations.
    • isImageProcessingEnabled

      public boolean isImageProcessingEnabled()
      Returns true if image processing is performed on image.
      Returns:
      true if image processing is performed on image.
    • setDocumentType

      @NonNull public BlinkOCREngineOptions setDocumentType(@NonNull OcrDocumentType documentType)
      Specifies the OCR document type that will be used to adjust the ocr engine settings. Every document type has specific set of characters and ocr engine settings.
      By default it is set to OcrDocumentType.OCR_DOCUMENT_TYPE_GENERIC. Default OCR document type is the best option in most cases and should not be changed unless the specific type is required.
      Parameters:
      documentType - Desired OCR document type that will be used to adjust the ocr engine settings.
      Returns:
      this object, to support chaining of operations.
    • getDocumentType

      @NonNull public OcrDocumentType getDocumentType()
      Returns the current OCR document type. See setDocumentType(OcrDocumentType).
      Returns:
      Current OCR document type for OCR engine.
    • addCharToWhitelist

      @NonNull public BlinkOCREngineOptions addCharToWhitelist(@NonNull BlinkOCRCharKey charKey)
      Adds a char+font combination to set of allowed chars. For example to define char 'k' in font Arial, use addCharToWhitelist(new BlinkOCRCharKey((int) 'k', BlinkOCRFont.ARIAL));

      For example to define char 'ü' in any font, use addCharToWhitelist(new BlinkOCRCharKey((int) 'ü', BlinkOCRFont.ANY));

      Parameters:
      charKey - char+font combination that should be allowed
      Returns:
      this object, to support chaining of operations.
    • addCharToWhitelist

      @NonNull public BlinkOCREngineOptions addCharToWhitelist(char value, @NonNull OcrFont font)
      Adds a char+font combination to set of allowed chars. For example to define char 'k' in font Arial, use addCharToWhitelist('k', BlinkOCRFont.ARIAL);

      For example to define char 'ü' in any font, use addCharToWhitelist('ü', BlinkOCRFont.ANY);

      Parameters:
      value - Value of the char. Whitespace characters are ignored.
      font - Font in which char will be allowed. Use OcrFont.ANY to cover all available fonts.
      Returns:
      this object, to support chaining of operations.
    • addCharIntervalToWhitelist

      @NonNull public BlinkOCREngineOptions addCharIntervalToWhitelist(char firstValue, char lastValue, @NonNull OcrFont font)
      Adds a interval of chars including first and last to whitelist in given font (use OcrFont.ANY to cover all available fonts).
      Parameters:
      firstValue - first char that will be added to whitelist
      lastValue - last char that will be added to whitelist
      font - font in which chars will be allowed. Use OcrFont.ANY to cover all available fonts.
      Returns:
      this object, to support chaining of operations.
    • addAllDigitsToWhitelist

      @NonNull public BlinkOCREngineOptions addAllDigitsToWhitelist(@NonNull OcrFont font)
      Adds all digits with given font to whitelist. This method is same as calling addCharIntervalToWhitelist('0', '9', font);
      Parameters:
      font - font in which chars will be allowed. Use OcrFont.ANY to cover all available fonts.
      Returns:
      this object, to support chaining of operations.
    • addLowercaseCharsToWhitelist

      @NonNull public BlinkOCREngineOptions addLowercaseCharsToWhitelist(@NonNull OcrFont font)
      Adds all lowercase ascii chars with given font to whitelist. This method is same as calling addCharIntervalToWhitelist('a', 'z', font);
      Parameters:
      font - font in which chars will be allowed. Use OcrFont.ANY to cover all available fonts.
      Returns:
      this object, to support chaining of operations.
    • addUppercaseCharsToWhitelist

      @NonNull public BlinkOCREngineOptions addUppercaseCharsToWhitelist(@NonNull OcrFont font)
      Adds all uppercase ascii chars with given font to whitelist. This method is same as calling addCharIntervalToWhitelist('A', 'Z', font);
      Parameters:
      font - font in which chars will be allowed. Use OcrFont.ANY to cover all available fonts.
      Returns:
      this object, to support chaining of operations.
    • allowAllCharsAndAllFonts

      @NonNull public BlinkOCREngineOptions allowAllCharsAndAllFonts()
      Allows all supported chars in all supported fonts.
      Returns:
      this object, to support chaining of operations.
    • setWordProcessingEnabled

      @NonNull public BlinkOCREngineOptions setWordProcessingEnabled(boolean wordProcessingEnabled)
      If the option is enabled, words in the OCR result will be processed and possibly classified as numbers, lower case words, upper case, ... . If this kind of classification is successful, the result will be altered.
      Returns:
      this object, to support chaining of operations.
    • isWordProcessingEnabled

      public boolean isWordProcessingEnabled()
      Returns whether word processing is enabled. See setWordProcessingEnabled(boolean)
      Returns:
      whether word processing is enabled. See setWordProcessingEnabled(boolean)
    • setDetectFlippedTextEnabled

      @NonNull public BlinkOCREngineOptions setDetectFlippedTextEnabled(boolean detectFlippedTextEnabled)
      If enabled, OCR will produce result for the input image and for input image rotated by 180 degrees. Better results of the two will be returned. Note that enabling this options requires two OCR passes, therefore double time will be required.
      Returns:
      this object, to support chaining of operations.
    • isDetectFlippedTextEnabled

      public boolean isDetectFlippedTextEnabled()
      Returns whether flipped text detection is enabled. See setDetectFlippedTextEnabled(boolean).
      Returns:
      whether flipped text detection is enabled. See setDetectFlippedTextEnabled(boolean).
    • setCasePostprocessorEnabled

      @NonNull public BlinkOCREngineOptions setCasePostprocessorEnabled(boolean casePostprocessorEnabled)
      If enabled, classification will be aided by character position in line. In other words, character height and baseline position will be used to possibly improve the result. Use this option only when expecting structured text.
      Returns:
      this object, to support chaining of operations.
    • isCasePostprocessorEnabled

      public boolean isCasePostprocessorEnabled()
      Returns whether case postprocessing is enabled. See setCasePostprocessorEnabled(boolean).
      Returns:
      whether case postprocessing is enabled. See setCasePostprocessorEnabled(boolean).
    • setNoisePostprocessingEnabled

      @NonNull public BlinkOCREngineOptions setNoisePostprocessingEnabled(boolean noisePostprocessingEnabled)
      If enabled noisy lines will be removed from the result. Noisy lines are short or with high percentage of punctuniation, ... . Use this option only when expecting structured text.
      Returns:
      this object, to support chaining of operations.
    • isNoisePostprocessingEnabled

      public boolean isNoisePostprocessingEnabled()
      Returns whether noise postprocessing is enabled. See setNoisePostprocessingEnabled(boolean).
      Returns:
      whether noise postprocessing is enabled. See setNoisePostprocessingEnabled(boolean).
    • setRatioPostprocessorEnabled

      @NonNull public BlinkOCREngineOptions setRatioPostprocessorEnabled(boolean ratioPostprocessorEnabled)
      If enabled, char quality will be influenced by character ratio difference from the original character in font specified by classification.
      Returns:
      this object, to support chaining of operations.
    • isRatioPostprocessorEnabled

      public boolean isRatioPostprocessorEnabled()
      Returns whether ratio postprocessor is enabled. See setRatioPostprocessorEnabled(boolean).
      Returns:
      whether ratio postprocessor is enabled. See setRatioPostprocessorEnabled(boolean).
    • setCutoffCharFilterEnabled

      @NonNull public BlinkOCREngineOptions setCutoffCharFilterEnabled(boolean cutoffCharFilterEnabled)
      If enabled, all chars that are classified as cutoff, in other words chars that exceed image bounds, will be removed from the result.
      Returns:
      this object, to support chaining of operations.
    • isCutoffCharFilterEnabled

      public boolean isCutoffCharFilterEnabled()
      Returns whether cutoff char filter is enabled. See setCutoffCharFilterEnabled(boolean).
      Returns:
      whether cutoff char filter is enabled. See setCutoffCharFilterEnabled(boolean).
    • terminateNative

      protected void terminateNative(long nativeContext)
      Specified by:
      terminateNative in class AbstractOCREngineOptions<BlinkOCREngineOptions>
    • serializeNative

      @NonNull protected byte[] serializeNative()
      Specified by:
      serializeNative in class AbstractOCREngineOptions<BlinkOCREngineOptions>
    • deserializeNative

      protected void deserializeNative(@NonNull byte[] bytes)
      Specified by:
      deserializeNative in class AbstractOCREngineOptions<BlinkOCREngineOptions>