RecognitionSettings
Inheritance: java.lang.Object
public class RecognitionSettings
Settings for the image recognition Contains elements that allow customizing the recognition process
Constructors
Constructor | Description |
---|---|
RecognitionSettings() | Default constructor: set recognitionAreas null, detectAreas true, autoSkew true, recognizeSingleLine false. |
RecognitionSettings(ArrayList | Constructor allows to set all options. |
RecognitionSettings(ArrayList | 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
Method | Description |
---|---|
setRecognitionAreas(ArrayList | 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:
Parameter | Type | Description |
---|---|---|
recognitionAreas | java.util.ArrayList<java.awt.Rectangle> | Rectangles for recognition. |
detectAreas | boolean | False for recognition as one area, true for dividing into areas before recognition. |
autoSkew | boolean | True if the image needs alignment. |
recognizeSingleLine | boolean | True 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:
Parameter | Type | Description |
---|---|---|
recognitionAreas | java.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:
Parameter | Type | Description |
---|---|---|
detectAreas | boolean | False for recognition as one area, true for dividing into areas before recognition. |
autoSkew | boolean | True 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:
Parameter | Type | Description |
---|---|---|
recognizeSingleLine | boolean | True if the image contains only one line. |
RecognitionSettings(DocumentRecognitionSettings docSettings)
public RecognitionSettings(DocumentRecognitionSettings docSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
docSettings | DocumentRecognitionSettings |
RecognitionSettings(ReceiptRecognitionSettings recSettings)
public RecognitionSettings(ReceiptRecognitionSettings recSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
recSettings | ReceiptRecognitionSettings |
RecognitionSettings(InvoiceRecognitionSettings recSettings)
public RecognitionSettings(InvoiceRecognitionSettings recSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
recSettings | InvoiceRecognitionSettings |
RecognitionSettings(IDCardRecognitionSettings recSettings)
public RecognitionSettings(IDCardRecognitionSettings recSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
recSettings | IDCardRecognitionSettings |
RecognitionSettings(PassportRecognitionSettings recSettings)
public RecognitionSettings(PassportRecognitionSettings recSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
recSettings | PassportRecognitionSettings |
RecognitionSettings(CarPlateRecognitionSettings recSettings)
public RecognitionSettings(CarPlateRecognitionSettings recSettings)
Parameters:
Parameter | Type | Description |
---|---|---|
recSettings | CarPlateRecognitionSettings |
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:
Parameter | Type | Description |
---|---|---|
recognitionAreas | java.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:
Parameter | Type | Description |
---|---|---|
detectAreas | boolean | Detect and split if true. |
setLinesFiltration(boolean linesFiltration)
public void setLinesFiltration(boolean linesFiltration)
Allows to recognize text in the tables (regions surrounded lines).
Parameters:
Parameter | Type | Description |
---|---|---|
linesFiltration | boolean | false - 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:
Parameter | Type | Description |
---|---|---|
autoSkew | boolean | Detect 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:
Parameter | Type | Description |
---|---|---|
recognizeSingleLine | boolean | True 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:
Parameter | Type | Description |
---|---|---|
skew | double | Rotate image on specified angle. |
setLanguage(Language language)
public void setLanguage(Language language)
Parameters:
Parameter | Type | Description |
---|---|---|
language | Language | Sets the language used for OCR. Multi-language (none) by default. |
setIgnoredCharacters(String characters)
public void setIgnoredCharacters(String characters)
Sets blacklist for recognition symbols.
Parameters:
Parameter | Type | Description |
---|---|---|
characters | java.lang.String | Characters excluded from recognition. |
setThresholdValue(int threshold)
public void setThresholdValue(int threshold)
Sets custom threshold value for image binarization.
Parameters:
Parameter | Type | Description |
---|---|---|
threshold | int | Range 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:
Parameter | Type | Description |
---|---|---|
threadsCount | int | the 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:
Parameter | Type | Description |
---|---|---|
preprocessingFilters | PreprocessingFilter | contains 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:
Parameter | Type | Description |
---|---|---|
autoContrast | boolean | contains 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:
Parameter | Type | Description |
---|---|---|
autoDenoising | boolean | contains 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:
Parameter | Type | Description |
---|---|---|
allowedCharacters | CharactersAllowedType | contains 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:
Parameter | Type | Description |
---|---|---|
allowedCharacters | java.lang.String | contains array of characters. |
setDetectAreasMode(DetectAreasMode detectAreasMode)
public void setDetectAreasMode(DetectAreasMode detectAreasMode)
Determines the type of neural network used for areas detection.
Parameters:
Parameter | Type | Description |
---|---|---|
detectAreasMode | DetectAreasMode | contains 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:
Parameter | Type | Description |
---|---|---|
upscaleSmallFont | boolean | contains boolean value - a upscaleSmallFont is set. |