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
Options used in legacy BlinkOCR engine.
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final android.os.Parcelable.Creator<BlinkOCREngineOptions>
Parcelable creator.Fields inherited from class com.microblink.photopay.entities.ocrengine.AbstractOCREngineOptions
mNativeContext
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.BlinkOCREngineOptions
(long nativeContext, Object keep) Constructor from native object. -
Method Summary
Modifier and TypeMethodDescriptionAdds all digits with given font to whitelist.addCharIntervalToWhitelist
(char firstValue, char lastValue, OcrFont font) Adds a interval of chars including first and last to whitelist in given font (use OcrFont.ANY to cover all available fonts).addCharToWhitelist
(char value, OcrFont font) Adds a char+font combination to set of allowed chars.addCharToWhitelist
(BlinkOCRCharKey charKey) Adds a char+font combination to set of allowed chars.Adds all lowercase ascii chars with given font to whitelist.Adds all uppercase ascii chars with given font to whitelist.Allows all supported chars in all supported fonts.clone()
Creates a copy ofBlinkOCREngineOptions
object.protected void
deserializeNative
(byte[] bytes) Returns the current OCR document type.final int
Returns the maximum height of the line of text given in pixels.final int
Returns the minimum height of char that can be classified.final int
Returns the minimum height of the line of text given in pixels.boolean
Returns whether case postprocessing is enabled.boolean
Returns whether cutoff char filter is enabled.boolean
Returns whether flipped text detection is enabled.boolean
Returns true if image processing is performed on image.boolean
Returns whether noise postprocessing is enabled.boolean
Returns whether ratio postprocessor is enabled.boolean
Returns whether word processing is enabled.protected byte[]
setCasePostprocessorEnabled
(boolean casePostprocessorEnabled) If enabled, classification will be aided by character position in line.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.setDetectFlippedTextEnabled
(boolean detectFlippedTextEnabled) If enabled, OCR will produce result for the input image and for input image rotated by 180 degrees.setDocumentType
(OcrDocumentType documentType) Specifies the OCR document type that will be used to adjust the ocr engine settings.setImageProcessingEnabled
(boolean imageProcessingEnabled) Specifies if the image processing is performed on image By default it's set to true.final BlinkOCREngineOptions
setMaximumLineHeight
(int maximumLineHeight) Sets the maximum height of the line of text given in pixels.final BlinkOCREngineOptions
setMinimumCharHeight
(int minimumCharHeight) Sets the minimum height of the char that can be classified.final BlinkOCREngineOptions
setMinimumLineHeight
(int minimumLineHeight) Sets the minimum height of the line of text given in pixels.setNoisePostprocessingEnabled
(boolean noisePostprocessingEnabled) If enabled noisy lines will be removed from the result.setRatioPostprocessorEnabled
(boolean ratioPostprocessorEnabled) If enabled, char quality will be influenced by character ratio difference from the original character in font specified by classification.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, ...protected void
terminateNative
(long nativeContext) Methods inherited from class com.microblink.photopay.entities.ocrengine.AbstractOCREngineOptions
describeContents, finalize, getMaximumAllowedCharRecognitionVariants, getMaximumCharsExpected, getNativeContext, isColorDropoutEnabled, setColorDropoutEnabled, setMaximumAllowedCharRecognitionVariants, setMaximumCharsExpected, writeToParcel
-
Field Details
-
CREATOR
Parcelable creator.
-
-
Constructor Details
-
BlinkOCREngineOptions
public BlinkOCREngineOptions()Default constructor. -
BlinkOCREngineOptions
Constructor from native object.- Parameters:
nativeContext
- Native engine options object.keep
- Owner of the native engine options object.
-
-
Method Details
-
clone
Creates a copy ofBlinkOCREngineOptions
object. -
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. UnlikesetMinimumLineHeight(int)
, this value refers to individual chars, whilesetMinimumLineHeight(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
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
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 toOcrDocumentType.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
Returns the current OCR document type. SeesetDocumentType(OcrDocumentType)
.- Returns:
- Current OCR document type for OCR engine.
-
addCharToWhitelist
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
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 whitelistlastValue
- last char that will be added to whitelistfont
- font in which chars will be allowed. Use OcrFont.ANY to cover all available fonts.- Returns:
- this object, to support chaining of operations.
-
addAllDigitsToWhitelist
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
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
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
Allows all supported chars in all supported fonts.- Returns:
- this object, to support chaining of operations.
-
setWordProcessingEnabled
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. SeesetWordProcessingEnabled(boolean)
- Returns:
- whether word processing is enabled. See
setWordProcessingEnabled(boolean)
-
setDetectFlippedTextEnabled
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. SeesetDetectFlippedTextEnabled(boolean)
.- Returns:
- whether flipped text detection is enabled. See
setDetectFlippedTextEnabled(boolean)
.
-
setCasePostprocessorEnabled
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. SeesetCasePostprocessorEnabled(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. SeesetNoisePostprocessingEnabled(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. SeesetRatioPostprocessorEnabled(boolean)
.- Returns:
- whether ratio postprocessor is enabled. See
setRatioPostprocessorEnabled(boolean)
.
-
setCutoffCharFilterEnabled
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. SeesetCutoffCharFilterEnabled(boolean)
.- Returns:
- whether cutoff char filter is enabled. See
setCutoffCharFilterEnabled(boolean)
.
-
terminateNative
protected void terminateNative(long nativeContext) - Specified by:
terminateNative
in classAbstractOCREngineOptions<BlinkOCREngineOptions>
-
serializeNative
@NonNull protected byte[] serializeNative()- Specified by:
serializeNative
in classAbstractOCREngineOptions<BlinkOCREngineOptions>
-
deserializeNative
protected void deserializeNative(@NonNull byte[] bytes) - Specified by:
deserializeNative
in classAbstractOCREngineOptions<BlinkOCREngineOptions>
-