com.aspose.ocr

## Class OCRConfig

- java.lang.Object
- - com.aspose.ocr.OCRConfig

-     public final class OCRConfig
      extends Object

  Configuration for OCR system.

  >      OcrEngine ocr = new OcrEngine();
  >      ocr.getConfig().setNeedRotationCorrection(false);

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OCRConfig()` Creates example of `OCRConfig` with default parameteres values

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRecognitionBlock(IRecognitionBlock recognitionBlock)` Adds a rectangular block to user defined RecognitionBlocks
    `void` | `clearRecognitionBlocks()` Clear recognition blocks array.
    `AdjustRotationMode` | `getAdjustRotation()` Gets a value of adjust rotation mode `AdjustRotationMode`.
    `double` | `getAdjustRotationAngle()` Gets a value of clockwise rotation angle, in degrees.
    `AdjustUpsideDownRotationMode` | `getAdjustUpsideDownRotation()` Gets a value of adjust upsidedown rotation mode `AdjustUpsideDownRotationMode`.
    `CorrectionFilters` | `getCorrectionFilters()` Gets filters for correction before recognition
    `boolean` | `getDeleteTableLines()` Gets a value that indicates whether need to find and delete table lines in document Don't use this property unnecessarily, because it may remove some meaningful information from the image and will increase total processing time
    `boolean` | `getDetectReadingOrder()` Gets a value that indicates whether special reading order detection operation must be applied to textblocks Default value is TRUE If OCR process works too much time or is not responding, try to set this property to FALSE
    `boolean` | `getDetectTextRegions()` Gets a value indicating whether automatical detection of the regions with text must be used.
    `IDictionaryReader` | `getDictionaryReader()` Gets any of available dictionary readers for post processing, if not set, post processing is not turned on.
    `boolean` | `getDoSpellingCorrection()` Gets a value indicating whether automatic spelling correction should be applied.
    `int` | `getProbabilityRow()` Gets row with probable symbols to return probable symbols from.
    `boolean` | `getProcessColoredBackground()` Turn on this option if input image have complex colored background, and standard method of thresholding work bad
    `int` | `getQuantizationPalleteSize()` It is advanced option, which control number of colors to image pallete while quantization; this option make sence olny if ProcessColoredBackground is true; defalt value if 5
    `List<IRecognitionBlock>` | `getRecognitionBlocks()` User defined blocks that determines page layout
    `boolean` | `getRemoveNonText()` Set this parameter to TRUE if image contains non-text components (e.g.
    `boolean` | `getUseDefaultDictionaries()` If getDictionaryReader() is null, this method indicates whether to use default dictionaries
    `void` | `setAdjustRotation(AdjustRotationMode value)` Sets a value of adjust rotation mode `AdjustRotationMode`.
    `void` | `setAdjustRotationAngle(double value)` Sets a value of clockwise rotation angle, in degrees.
    `void` | `setAdjustUpsideDownRotation(AdjustUpsideDownRotationMode value)` Sets a value of adjust upsidedown rotation mode `AdjustUpsideDownRotationMode`.
    `void` | `setCorrectionFilters(CorrectionFilters value)` Sets filters for correction before recognition
    `void` | `setDeleteTableLines(boolean value)` Sets a value that indicates whether need to find and delete table lines in document Don't use this property unnecessarily, because it may remove some meaningful information from the image and will increase total processing time
    `void` | `setDetectReadingOrder(boolean value)` Sets a value that indicates whether special reading order detection operation must be applied to textblocks Default value is TRUE If OCR process works too much time or is not responding, try to set this property to FALSE
    `void` | `setDetectTextRegions(boolean value)` Sets a value indicating whether automatical detection of the regions with text must be used.
    `void` | `setDictionaryReader(IDictionaryReader value)` Sets available dictionary readers for post processing.
    `void` | `setDoSpellingCorrection(boolean value)` Sets a value indicating whether automatic spelling correction should be applied.
    `void` | `setProbabilityRow(int value)` Sets row with probable symbols to return probable symbols from.
    `void` | `setProcessColoredBackground(boolean value)` Turn on this option if input image have complex colored background, and standard method of thresholding work bad
    `void` | `setQuantizationPalleteSize(int value)` It is advanced option, which control number of colors to image pallete while quantization; this option make sence olny if ProcessColoredBackground is true; defalt value if 5
    `void` | `setRemoveNonText(boolean value)` Set this parameter to TRUE if image contains non-text components (e.g.
    `void` | `setUseDefaultDictionaries(boolean value)` If getDictionaryReader() is null, this method specifies whether to use default dictionaries

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OCRConfig

          public OCRConfig()

      Creates example of `OCRConfig` with default parameteres values

  - ### Method Detail

    - #### addRecognitionBlock

          public void addRecognitionBlock(IRecognitionBlock recognitionBlock)

      Adds a rectangular block to user defined RecognitionBlocks

      Parameters:
        `recognitionBlock` - a block to add

    - #### clearRecognitionBlocks

          public void clearRecognitionBlocks()

      Clear recognition blocks array.

    - #### getAdjustRotation

          public AdjustRotationMode getAdjustRotation()

      Gets a value of adjust rotation mode `AdjustRotationMode`. Possible values: `AdjustRotationMode.Automatic` - skew angle is defined automatically (this may take some time but will improve recognition quality) `AdjustRotationMode.UserDefined` - image is rotated on angle defined in `AdjustRotationAngle` `AdjustRotationMode.Disabled` - no image rotation will be applied

      Returns:
        a value of adjust rotation mode

    - #### getAdjustRotationAngle

          public double getAdjustRotationAngle()

      Gets a value of clockwise rotation angle, in degrees. Use only when AdjustRotation is equal AdjustRotationMode.UserDefined.

      Returns:
        the adjust rotation angle

    - #### getAdjustUpsideDownRotation

          public AdjustUpsideDownRotationMode getAdjustUpsideDownRotation()

      Gets a value of adjust upsidedown rotation mode `AdjustUpsideDownRotationMode`.

      Returns:
        a value of adjust upsidedown rotation mode

    - #### getCorrectionFilters

          public CorrectionFilters getCorrectionFilters()

      Gets filters for correction before recognition

      Returns:
        the correction filters

    - #### getDeleteTableLines

          public boolean getDeleteTableLines()

      Gets a value that indicates whether need to find and delete table lines in document Don't use this property unnecessarily, because it may remove some meaningful information from the image and will increase total processing time

      Returns:
        a value that indicates whether need to find and delete table lines in document

    - #### getDetectReadingOrder

          public boolean getDetectReadingOrder()

      Gets a value that indicates whether special reading order detection operation must be applied to textblocks Default value is TRUE If OCR process works too much time or is not responding, try to set this property to FALSE

      >       OcrEngine ocr = new OcrEngine();
      >       ocr.setImage(ImageStream.fromFile("image.tiff"));
      >       ocr.getLanguages().addLanguage(Language.load("english"));
      >       ocr.getConfig().setDetectReadingOrder(false);

      >       FileInputStream resourceStream = new FileInputStream(resourceFileName);
      >       ocr.setResource(resourceStream);

      >       if (ocr.process()) {
      >           System.out.println(ocr.getText());
      >       }

      Returns:
        a value that indicates whether special reading order detection operation must be applied to textblocks

    - #### getDetectTextRegions

          public boolean getDetectTextRegions()

      Gets a value indicating whether automatical detection of the regions with text must be used. If this property is set to "true", manually set recognition blocks will be ignored.

      Returns:
        a value indicating whether automatical detection of the regions with text must be used

    - #### getDictionaryReader

          public IDictionaryReader getDictionaryReader()

      Gets any of available dictionary readers for post processing, if not set, post processing is not turned on.

      Returns:
        the dictionary reader

    - #### getDoSpellingCorrection

          public boolean getDoSpellingCorrection()

      Gets a value indicating whether automatic spelling correction should be applied. Use this option to improve OCR result but notice that this will increase total processing time

      Returns:
        a value indicating whether automatic spelling correction should be applied

    - #### getProbabilityRow

          public int getProbabilityRow()

      Gets row with probable symbols to return probable symbols from. Default value is 0, so only the most probable symbols return.

      Returns:
        the probability row

    - #### getProcessColoredBackground

          public boolean getProcessColoredBackground()

      Turn on this option if input image have complex colored background, and standard method of thresholding work bad

      Returns:
        `true` if should process colored background

    - #### getQuantizationPalleteSize

          public int getQuantizationPalleteSize()

      It is advanced option, which control number of colors to image pallete while quantization; this option make sence olny if ProcessColoredBackground is true; defalt value if 5

      Returns:
        the quantization pallete size

    - #### getRecognitionBlocks

          public List<IRecognitionBlock> getRecognitionBlocks()

      User defined blocks that determines page layout

      Returns:
        User defined blocks that determines page layout

    - #### getRemoveNonText

          public boolean getRemoveNonText()

      Set this parameter to TRUE if image contains non-text components (e.g. pictures, graphics) that should be detected and ignored during recognition process

      Returns:
        true if non-text components should be removed from the image.

    - #### getUseDefaultDictionaries

          public boolean getUseDefaultDictionaries()

      If getDictionaryReader() is null, this method indicates whether to use default dictionaries

      Returns:
        `true` if use default dictionaries

    - #### setAdjustRotation

          public void setAdjustRotation(AdjustRotationMode value)

      Sets a value of adjust rotation mode `AdjustRotationMode`. Possible values: `AdjustRotationMode.Automatic` - skew angle is defined automatically (this may take some time but will improve recognition quality) `AdjustRotationMode.UserDefined` - image is rotated on angle defined in `AdjustRotationAngle` `AdjustRotationMode.Disabled` - no image rotation will be applied

      Parameters:
        `value` - a value of adjust rotation mode

    - #### setAdjustRotationAngle

          public void setAdjustRotationAngle(double value)

      Sets a value of clockwise rotation angle, in degrees. Use only when AdjustRotation is equal AdjustRotationMode.UserDefined.

      Parameters:
        `value` - a value of clockwise rotation angle

    - #### setAdjustUpsideDownRotation

          public void setAdjustUpsideDownRotation(AdjustUpsideDownRotationMode value)

      Sets a value of adjust upsidedown rotation mode `AdjustUpsideDownRotationMode`. Set it to `AdjustUpsideDownRotationMode.Flip` if text on image is upsidedown so it will be rotated to 180 degrees

      Parameters:
        `value` - a value of adjust upsidedown rotation mode

    - #### setCorrectionFilters

          public void setCorrectionFilters(CorrectionFilters value)

      Sets filters for correction before recognition

      Parameters:
        `value` - filters for correction before recognition

    - #### setDeleteTableLines

          public void setDeleteTableLines(boolean value)

      Sets a value that indicates whether need to find and delete table lines in document Don't use this property unnecessarily, because it may remove some meaningful information from the image and will increase total processing time

      >       OcrEngine ocr = new OcrEngine();
      >       ocr.setImage(ImageStream.fromFile("image.tiff"));
      >       ocr.getLanguages().addLanguage(Language.load("english"));
      >       ocr.getConfig().setDeleteTableLines(true);

      >       FileInputStream resourceStream = new FileInputStream(resourceFileName);
      >       ocr.setResource(resourceStream);

      >       if (ocr.process()) {
      >           System.out.println(ocr.getText());
      >       }

      Parameters:
        `value` - a value that indicates whether need to find and delete table lines in document

    - #### setDetectReadingOrder

          public void setDetectReadingOrder(boolean value)

      Sets a value that indicates whether special reading order detection operation must be applied to textblocks Default value is TRUE If OCR process works too much time or is not responding, try to set this property to FALSE

      >       OcrEngine ocr = new OcrEngine();
      >       ocr.setImage(ImageStream.fromFile("image.tiff"));
      >       ocr.getLanguages().addLanguage(Language.load("english"));
      >       ocr.getConfig().setDetectReadingOrder(false);

      >       FileInputStream resourceStream = new FileInputStream(resourceFileName);
      >       ocr.setResource(resourceStream);

      >       if (ocr.process()) {
      >           System.out.println(ocr.getText());
      >       }

      Parameters:
        `value` - a value that indicates whether special reading order detection operation must be applied to textblocks

    - #### setDetectTextRegions

          public void setDetectTextRegions(boolean value)

      Sets a value indicating whether automatical detection of the regions with text must be used. If this property is set to "true", manually set recognition blocks will be ignored.

      Parameters:
        `value` - a value indicating whether automatical detection of the regions with text must be used

    - #### setDictionaryReader

          public void setDictionaryReader(IDictionaryReader value)

      Sets available dictionary readers for post processing. This value (if not null) overrides value set by setUseDefaultDictionaries().

      Parameters:
        `value` - available dictionary readers for post processing

    - #### setDoSpellingCorrection

          public void setDoSpellingCorrection(boolean value)

      Sets a value indicating whether automatic spelling correction should be applied. Use this option to improve OCR result but notice that this will increase total processing time

      >       OcrEngine ocr = new OcrEngine();
      >       ocr.setImage(ImageStream.fromFile("image.tiff"));
      >       ocr.getLanguages().addLanguage(Language.load("english"));
      >       ocr.getConfig().setDoSpellingCorrection(true);

      >       FileInputStream resourceStream = new FileInputStream(resourceFileName);
      >       ocr.setResource(resourceStream);

      >       if (ocr.process()) {
      >           System.out.println(ocr.getText());
      >       }

      Parameters:
        `value` - a value indicating whether automatic spelling correction should be applied

    - #### setProbabilityRow

          public void setProbabilityRow(int value)

      Sets row with probable symbols to return probable symbols from.

      Parameters:
        `value` - the row with probable symbols

    - #### setProcessColoredBackground

          public void setProcessColoredBackground(boolean value)

      Turn on this option if input image have complex colored background, and standard method of thresholding work bad

      Parameters:
        `value` - `true` if should process colored background

    - #### setQuantizationPalleteSize

          public void setQuantizationPalleteSize(int value)

      It is advanced option, which control number of colors to image pallete while quantization; this option make sence olny if ProcessColoredBackground is true; defalt value if 5

      Parameters:
        `value` - the value for the quantization pallete size

    - #### setRemoveNonText

          public void setRemoveNonText(boolean value)

      Set this parameter to TRUE if image contains non-text components (e.g. pictures, graphics) that should be detected and ignored during recognition process

      >       OcrEngine ocr = new OcrEngine();
      >       ocr.setImage(ImageStream.fromFile("image.tiff"));
      >       ocr.getLanguages().addLanguage(Language.load("english"));
      >       ocr.getConfig().setRemoveNonText(true);

      >       FileInputStream resourceStream = new FileInputStream(resourceFileName);
      >       ocr.setResource(resourceStream);

      >       if (ocr.process()) {
      >           System.out.println(ocr.getText());
      >       }

      Parameters:
        `value` - true if non-text components should be removed from the image.

    - #### setUseDefaultDictionaries

          public void setUseDefaultDictionaries(boolean value)

      If getDictionaryReader() is null, this method specifies whether to use default dictionaries

      Parameters:
        `value` - `true` if use default dictionaries

Copyright © 2014. All rights reserved.