RecognitionSettings

Inheritance: java.lang.Object

public class RecognitionSettings

Settings for the image recognition Contains elements that allow customizing the recognition process

Constructors

ConstructorDescription
RecognitionSettings()Default constructor: set recognitionAreas null, detectAreas true, autoSkew true, recognizeSingleLine false.
RecognitionSettings(ArrayList recognitionAreas, boolean detectAreas, boolean autoSkew, boolean recognizeSingleLine)Constructor allows to set all options.
RecognitionSettings(ArrayList recognitionAreas)Constructor allows to set recognitionAreas.
RecognitionSettings(boolean detectAreas, boolean autoSkew)Constructor allows to set detectAreas and autoSkew.
RecognitionSettings(boolean recognizeSingleLine)Constructor allows to set recognizeSingleLine.
RecognitionSettings(DocumentRecognitionSettings docSettings)
RecognitionSettings(ReceiptRecognitionSettings recSettings)
RecognitionSettings(InvoiceRecognitionSettings recSettings)
RecognitionSettings(IDCardRecognitionSettings recSettings)
RecognitionSettings(PassportRecognitionSettings recSettings)
RecognitionSettings(CarPlateRecognitionSettings recSettings)

Methods

MethodDescription
setRecognitionAreas(ArrayList recognitionAreas)Sets the list of text areas for processing.
setDetectAreas(boolean detectAreas)Sets a flag indicating whether automatic text areas detection should be enabled.
setLinesFiltration(boolean linesFiltration)Allows to recognize text in the tables (regions surrounded lines).
setAutoSkew(boolean autoSkew)Sets a flag indicating whether automatic image skew correction should be enabled.
setRecognizeSingleLine(boolean recognizeSingleLine)Sets single-line image recognition.
setSkew(double skew)Sets angle in degrees for image rotation.
setLanguage(Language language)
setIgnoredCharacters(String characters)Sets blacklist for recognition symbols.
setThresholdValue(int threshold)Sets custom threshold value for image binarization.
setThreadsCount(int threadsCount)Gets or sets the number of threads for processing.
setPreprocessingFilters(PreprocessingFilter preprocessingFilters)Allows to prepare the image for OCR by adjusting pre-processing methods.
setAutoContrast(boolean autoContrast)Allows using an additional contrast correction algorithm for the image before recognition.
setAutoDenoising(boolean autoDenoising)Enables the use of an additional neural network to improve the image - reduce noise.
setAllowedCharacters(CharactersAllowedType allowedCharacters)Allowed characters set.
setAllowedCharacters(String allowedCharacters)Allowed characters set.
setDetectAreasMode(DetectAreasMode detectAreasMode)Determines the type of neural network used for areas detection.
setUpscaleSmallFont(boolean upscaleSmallFont)Allows you to use additional algorithms specifically for small font recognition.

RecognitionSettings()

public RecognitionSettings()

Default constructor: set recognitionAreas null, detectAreas true, autoSkew true, recognizeSingleLine false.

RecognitionSettings(ArrayList recognitionAreas, boolean detectAreas, boolean autoSkew, boolean recognizeSingleLine)

public RecognitionSettings(ArrayList<Rectangle> recognitionAreas, boolean detectAreas, boolean autoSkew, boolean recognizeSingleLine)

Constructor allows to set all options.

Parameters:

ParameterTypeDescription
recognitionAreasjava.util.ArrayList<java.awt.Rectangle>Rectangles for recognition.
detectAreasbooleanFalse for recognition as one area, true for dividing into areas before recognition.
autoSkewbooleanTrue if the image needs alignment.
recognizeSingleLinebooleanTrue if the image contains only one line.

RecognitionSettings(ArrayList recognitionAreas)

public RecognitionSettings(ArrayList<Rectangle> recognitionAreas)

Constructor allows to set recognitionAreas. Default values in this case: detectAreas - false, autoSkew = false, recognizeSingleLine - false.

Parameters:

ParameterTypeDescription
recognitionAreasjava.util.ArrayList<java.awt.Rectangle>Rectangles for recognition.

RecognitionSettings(boolean detectAreas, boolean autoSkew)

public RecognitionSettings(boolean detectAreas, boolean autoSkew)

Constructor allows to set detectAreas and autoSkew. Default values in this case: recognizeSingleLine - false, recognitionAreas - null.

Parameters:

ParameterTypeDescription
detectAreasbooleanFalse for recognition as one area, true for dividing into areas before recognition.
autoSkewbooleanTrue if the image needs alignment.

RecognitionSettings(boolean recognizeSingleLine)

public RecognitionSettings(boolean recognizeSingleLine)

Constructor allows to set recognizeSingleLine. Default values in this case: detectAreas - false, autoSkew = false, recognitionAreas - null.

Parameters:

ParameterTypeDescription
recognizeSingleLinebooleanTrue if the image contains only one line.

RecognitionSettings(DocumentRecognitionSettings docSettings)

public RecognitionSettings(DocumentRecognitionSettings docSettings)

Parameters:

ParameterTypeDescription
docSettingsDocumentRecognitionSettings

RecognitionSettings(ReceiptRecognitionSettings recSettings)

public RecognitionSettings(ReceiptRecognitionSettings recSettings)

Parameters:

ParameterTypeDescription
recSettingsReceiptRecognitionSettings

RecognitionSettings(InvoiceRecognitionSettings recSettings)

public RecognitionSettings(InvoiceRecognitionSettings recSettings)

Parameters:

ParameterTypeDescription
recSettingsInvoiceRecognitionSettings

RecognitionSettings(IDCardRecognitionSettings recSettings)

public RecognitionSettings(IDCardRecognitionSettings recSettings)

Parameters:

ParameterTypeDescription
recSettingsIDCardRecognitionSettings

RecognitionSettings(PassportRecognitionSettings recSettings)

public RecognitionSettings(PassportRecognitionSettings recSettings)

Parameters:

ParameterTypeDescription
recSettingsPassportRecognitionSettings

RecognitionSettings(CarPlateRecognitionSettings recSettings)

public RecognitionSettings(CarPlateRecognitionSettings recSettings)

Parameters:

ParameterTypeDescription
recSettingsCarPlateRecognitionSettings

setRecognitionAreas(ArrayList recognitionAreas)

public void setRecognitionAreas(ArrayList<Rectangle> recognitionAreas)

Sets the list of text areas for processing. Allows to manually specify the areas with text for more accurate recognition. If custom areas are set setDetectAreas(boolean) and setAutoSkew(boolean) properties will be ignored. Disables DetectAreas and AutoSkew.

Parameters:

ParameterTypeDescription
recognitionAreasjava.util.ArrayList<java.awt.Rectangle>Rectangles for recognition.

setDetectAreas(boolean detectAreas)

public void setDetectAreas(boolean detectAreas)

Sets a flag indicating whether automatic text areas detection should be enabled. Enables Document Structure Recognition module. This takes more time and memory to process an image, but provides more accurate results on complex cases. Disable (set to false) for faster image processing or in case of images with simple structure.

Parameters:

ParameterTypeDescription
detectAreasbooleanDetect and split if true.

setLinesFiltration(boolean linesFiltration)

public void setLinesFiltration(boolean linesFiltration)

Allows to recognize text in the tables (regions surrounded lines).

Parameters:

ParameterTypeDescription
linesFiltrationbooleanfalse - allows increase performance and don’t detect tables and remove lines; otherwise - true. Disabled (false) by default.

setAutoSkew(boolean autoSkew)

public void setAutoSkew(boolean autoSkew)

Sets a flag indicating whether automatic image skew correction should be enabled. Enabled (true) by default.

Parameters:

ParameterTypeDescription
autoSkewbooleanDetect and rotate if true.

setRecognizeSingleLine(boolean recognizeSingleLine)

public void setRecognizeSingleLine(boolean recognizeSingleLine)

Sets single-line image recognition. Disabled (false) by default. Disable all the processing steps associated with splitting into lines. Set this parameter to true if your image contains only one line. Disables setRecognitionAreas(ArrayList) settings, so all areas settings will be ignored.

Parameters:

ParameterTypeDescription
recognizeSingleLinebooleanTrue for single-line image

setSkew(double skew)

public void setSkew(double skew)

Sets angle in degrees for image rotation. Zero by default. Setting this value will disable the setAutoSkew(boolean) property, so that auto skew correction is not applied.

Parameters:

ParameterTypeDescription
skewdoubleRotate image on specified angle.

setLanguage(Language language)

public void setLanguage(Language language)

Parameters:

ParameterTypeDescription
languageLanguageSets the language used for OCR. Multi-language (none) by default.

setIgnoredCharacters(String characters)

public void setIgnoredCharacters(String characters)

Sets blacklist for recognition symbols.

Parameters:

ParameterTypeDescription
charactersjava.lang.StringCharacters excluded from recognition.

setThresholdValue(int threshold)

public void setThresholdValue(int threshold)

Sets custom threshold value for image binarization.

Parameters:

ParameterTypeDescription
thresholdintRange from 1 to 255.

setThreadsCount(int threadsCount)

public void setThreadsCount(int threadsCount)

Gets or sets the number of threads for processing. By default, 0 means that the image will be processed with the number of threads equal to your number of processors. ThreadsCount = 1 means that the image will be processed in the main thread.

Parameters:

ParameterTypeDescription
threadsCountintthe number of threads that will be created for parallel recognition of image fragments.

setPreprocessingFilters(PreprocessingFilter preprocessingFilters)

public void setPreprocessingFilters(PreprocessingFilter preprocessingFilters)

Allows to prepare the image for OCR by adjusting pre-processing methods.

Parameters:

ParameterTypeDescription
preprocessingFiltersPreprocessingFiltercontains user preprocessing operations or null.

setAutoContrast(boolean autoContrast)

public void setAutoContrast(boolean autoContrast)

Allows using an additional contrast correction algorithm for the image before recognition.

Parameters:

ParameterTypeDescription
autoContrastbooleancontains boolean value - a contrast correction filter is set.

setAutoDenoising(boolean autoDenoising)

public void setAutoDenoising(boolean autoDenoising)

Enables the use of an additional neural network to improve the image - reduce noise. Useful for images with scan artifacts, distortion, spots, flares, gradients, foreign elements.

Parameters:

ParameterTypeDescription
autoDenoisingbooleancontains boolean value - a denoising is set.

setAllowedCharacters(CharactersAllowedType allowedCharacters)

public void setAllowedCharacters(CharactersAllowedType allowedCharacters)

Allowed characters set. Determines the type of characters allowed for recognition result.

Parameters:

ParameterTypeDescription
allowedCharactersCharactersAllowedTypecontains enum @see CharactersAllowedType value.

setAllowedCharacters(String allowedCharacters)

public void setAllowedCharacters(String allowedCharacters)

Allowed characters set. Determines the array of characters allowed for recognition result.

Parameters:

ParameterTypeDescription
allowedCharactersjava.lang.Stringcontains array of characters.

setDetectAreasMode(DetectAreasMode detectAreasMode)

public void setDetectAreasMode(DetectAreasMode detectAreasMode)

Determines the type of neural network used for areas detection.

Parameters:

ParameterTypeDescription
detectAreasModeDetectAreasModecontains enum @see DetectAreasMode value.

setUpscaleSmallFont(boolean upscaleSmallFont)

public void setUpscaleSmallFont(boolean upscaleSmallFont)

Allows you to use additional algorithms specifically for small font recognition. Useful for images with small size characters.

Parameters:

ParameterTypeDescription
upscaleSmallFontbooleancontains boolean value - a upscaleSmallFont is set.