com.aspose.ocr

Class RecognitionSettings



  • public class RecognitionSettings
    extends Object
    Settings for the image recognition Contains elements that allow customizing the recognition process
    • Constructor Detail

      • RecognitionSettings

        public RecognitionSettings()
        Default constructor: set recognitionAreas null, detectAreas true, autoSkew true, recognizeSingleLine false.
      • RecognitionSettings

        public RecognitionSettings(ArrayList<Rectangle> recognitionAreas,
                                   boolean detectAreas,
                                   boolean autoSkew,
                                   boolean recognizeSingleLine)
        Constructor allows to set all options.
        Parameters:
        recognitionAreas - Rectangles for recognition.
        detectAreas - False for recognition as one area, true for dividing into areas before recognition.
        autoSkew - True if the image needs alignment.
        recognizeSingleLine - True if the image contains only one line.
      • RecognitionSettings

        public RecognitionSettings(ArrayList<Rectangle> recognitionAreas)
        Constructor allows to set recognitionAreas. Default values in this case: detectAreas - false, autoSkew = false, recognizeSingleLine - false.
        Parameters:
        recognitionAreas - Rectangles for recognition.
      • RecognitionSettings

        public RecognitionSettings(boolean detectAreas,
                                   boolean autoSkew)
        Constructor allows to set detectAreas and autoSkew. Default values in this case: recognizeSingleLine - false, recognitionAreas - null.
        Parameters:
        detectAreas - False for recognition as one area, true for dividing into areas before recognition.
        autoSkew - True if the image needs alignment.
      • RecognitionSettings

        public RecognitionSettings(boolean recognizeSingleLine)
        Constructor allows to set recognizeSingleLine. Default values in this case: detectAreas - false, autoSkew = false, recognitionAreas - null.
        Parameters:
        recognizeSingleLine - True if the image contains only one line.
    • Method Detail

      • setRecognitionAreas

        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:
        recognitionAreas - Rectangles for recognition.
      • setDetectAreas

        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:
        detectAreas - Detect and split if true.
      • setLinesFiltration

        public void setLinesFiltration(boolean linesFiltration)
        Allows to recognize text in the tables (regions surrounded lines).
        Parameters:
        linesFiltration - false - allows increase performance and don't detect tables and remove lines; otherwise - true. Disabled (false) by default.
      • setAutoSkew

        public void setAutoSkew(boolean autoSkew)
        Sets a flag indicating whether automatic image skew correction should be enabled. Enabled (true) by default.
        Parameters:
        autoSkew - Detect and rotate if true.
      • setRecognizeSingleLine

        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:
        recognizeSingleLine - True for single-line image
      • setSkew

        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:
        skew - Rotate image on specified angle.
      • setLanguage

        public void setLanguage(Language language)
        Parameters:
        language - Sets the language used for OCR. Multi-language (none) by default.
      • setIgnoredCharacters

        public void setIgnoredCharacters(String characters)
        Sets blacklist for recognition symbols.
        Parameters:
        characters - Characters excluded from recognition.
      • setThresholdValue

        public void setThresholdValue(int threshold)
        Sets custom threshold value for image binarization.
        Parameters:
        threshold - Range from 1 to 255.
      • setThreadsCount

        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:
        threadsCount - the number of threads that will be created for parallel recognition of image fragments.
      • setPreprocessingFilters

        public void setPreprocessingFilters(PreprocessingFilter preprocessingFilters)
        Allows to prepare the image for OCR by adjusting pre-processing methods.
        Parameters:
        preprocessingFilters - contains user preprocessing operations or null.
      • setAutoContrast

        public void setAutoContrast(boolean autoContrast)
        Allows using an additional contrast correction algorithm for the image before recognition.
        Parameters:
        autoContrast - contains boolean value - a contrast correction filter is set.
      • setAllowedCharacters

        public void setAllowedCharacters(CharactersAllowedType allowedCharacters)
        Allowed characters set. Determines the type of characters allowed for recognition result.
        Parameters:
        allowedCharacters - contains enum @see CharactersAllowedType value.