eu.id3.document

## Class DocumentDetector

- java.lang.Object
- - eu.id3.document.DocumentDetector

- All Implemented Interfaces:
    java.io.Serializable, java.lang.AutoCloseable

      public class DocumentDetector
      extends java.lang.Object
      implements java.lang.AutoCloseable, java.io.Serializable

  Detects documents in images.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DocumentDetector()` Creates a new instance of the DocumentDetector class.
    `DocumentDetector(long handle)` Creates a new instance of the DocumentDetector class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DocumentImage` | `alignDocument(DocumentImage sourceImage, DetectedDocument detectedDocument)` Aligns and crops the specified document on the specified image and returns a new DocumentImage.
    `void` | `close()` Releases all resources used by this DocumentDetector.
    `DetectedDocument` | `detectDocument(DocumentImage image, Rectangle detectionZone)` Detects a document on a delimited area of the specified DocumentImage and returns a DetectedDocument.
    `DetectedDocument` | `detectDocumentByName(DocumentImage image, java.lang.String documentName, Rectangle detectionZone)` Detects a document with specified name on a delimited area of the specified DocumentImage and returns a DetectedDocument.
    `protected void` | `finalize()` Finalizer for this class.
    `int` | `getConfidenceThreshold()` Gets the confidence threshold, from 0 to 100+.
    `float` | `getDocumentWidthRatio()` Gets the ratio of the estimated width of the searched document in the image.
    `long` | `getHandle()` Gets the native handle.
    `DocumentModel` | `getModel()` Gets the model to be used for document detection.
    `ProcessingUnit` | `getProcessingUnit()` Gets the processing unit where to run the detection process.
    `int` | `getThreadCount()` Gets the number of threads to use for detection.
    `void` | `setConfidenceThreshold(int confidenceThreshold)` Sets the confidence threshold, from 0 to 100+.
    `void` | `setDocumentWidthRatio(float documentWidthRatio)` Sets the ratio of the estimated width of the searched document in the image.
    `void` | `setModel(DocumentModel model)` Sets the model to be used for document detection.
    `void` | `setProcessingUnit(ProcessingUnit processingUnit)` Sets the processing unit where to run the detection process.
    `void` | `setThreadCount(int threadCount)` Sets the number of threads to use for detection.

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

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

- - ### Constructor Detail

    - #### DocumentDetector

          public DocumentDetector()
                           throws DocumentException

      Creates a new instance of the DocumentDetector class.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### DocumentDetector

          public DocumentDetector(long handle)
                           throws DocumentException

      Creates a new instance of the DocumentDetector class.
      Parameters:
        `handle` - Handle to the DocumentDetector.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

  - ### Method Detail

    - #### close

          public void close()

      Releases all resources used by this DocumentDetector.
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### finalize

          protected void finalize()

      Finalizer for this class. Finalizers are deprecated since Java 9+. This method is not guaranteed to be called. To release all memory held by this class please be sure to call the close() method.
      Overrides:
        `finalize` in class `java.lang.Object`

    - #### getHandle

          public long getHandle()

      Gets the native handle.
      Returns:
        The native handle.

    - #### getConfidenceThreshold

          public int getConfidenceThreshold()
                                     throws DocumentException

      Gets the confidence threshold, from 0 to 100+. Hint: Default value is 50. Lower threshold can increase number of false detection.
      Returns:
        Confidence threshold, from 0 to 100+.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### setConfidenceThreshold

          public void setConfidenceThreshold(int confidenceThreshold)
                                      throws DocumentException

      Sets the confidence threshold, from 0 to 100+. Hint: Default value is 50. Lower threshold can increase number of false detection.
      Parameters:
        `confidenceThreshold` - Confidence threshold, from 0 to 100+.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### getDocumentWidthRatio

          public float getDocumentWidthRatio()
                                      throws DocumentException

      Gets the ratio of the estimated width of the searched document in the image. Hint: Default value is 1.
      Returns:
        Ratio of the estimated width of the searched document in the image.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### setDocumentWidthRatio

          public void setDocumentWidthRatio(float documentWidthRatio)
                                     throws DocumentException

      Sets the ratio of the estimated width of the searched document in the image. Hint: Default value is 1.
      Parameters:
        `documentWidthRatio` - Ratio of the estimated width of the searched document in the image.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### getModel

          public DocumentModel getModel()
                                 throws DocumentException

      Gets the model to be used for document detection. Hint: Default value is DocumentDetector2A.
      Returns:
        Model to be used for document detection.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### setModel

          public void setModel(DocumentModel model)
                        throws DocumentException

      Sets the model to be used for document detection. Hint: Default value is DocumentDetector2A.
      Parameters:
        `model` - Model to be used for document detection.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### getProcessingUnit

          public ProcessingUnit getProcessingUnit()
                                           throws DocumentException

      Gets the processing unit where to run the detection process. Hint: Default value is CPU.
      Returns:
        Processing unit where to run the detection process.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### setProcessingUnit

          public void setProcessingUnit(ProcessingUnit processingUnit)
                                 throws DocumentException

      Sets the processing unit where to run the detection process. Hint: Default value is CPU.
      Parameters:
        `processingUnit` - Processing unit where to run the detection process.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### getThreadCount

          public int getThreadCount()
                             throws DocumentException

      Gets the number of threads to use for detection. Hint: Default value is 1. Allocating more than 1 thread here can increase the speed of the process.
      Returns:
        Number of threads to use for detection.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### setThreadCount

          public void setThreadCount(int threadCount)
                              throws DocumentException

      Sets the number of threads to use for detection. Hint: Default value is 1. Allocating more than 1 thread here can increase the speed of the process.
      Parameters:
        `threadCount` - Number of threads to use for detection.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### alignDocument

          public DocumentImage alignDocument(DocumentImage sourceImage,
                                             DetectedDocument detectedDocument)
                                      throws DocumentException

      Aligns and crops the specified document on the specified image and returns a new DocumentImage.
      Parameters:
        `sourceImage` - The source image containing the document.
        `detectedDocument` - The detected document in the image.
      Returns:
        Realigned and cropped image of the document.
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### detectDocument

          public DetectedDocument detectDocument(DocumentImage image,
                                                 Rectangle detectionZone)
                                          throws DocumentException

      Detects a document on a delimited area of the specified DocumentImage and returns a DetectedDocument. Important: Document templates must be loaded before calling this method.
      Parameters:
        `image` - Source image to process
        `detectionZone` - Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.
      Returns:
        Detected document in the image
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

    - #### detectDocumentByName

          public DetectedDocument detectDocumentByName(DocumentImage image,
                                                       java.lang.String documentName,
                                                       Rectangle detectionZone)
                                                throws DocumentException

      Detects a document with specified name on a delimited area of the specified DocumentImage and returns a DetectedDocument. Important: The relevant document template must be loaded before calling this method.
      Parameters:
        `image` - The source image to process.
        `documentName` - The name of the document to be searched for. Must be a key loaded in DocumentLibrary.
        `detectionZone` - A delimited area in the image where to search for the document. Default is the full image. Output corners are in the full image referential.
      Returns:
        Detected document in the image
      Throws:
        `DocumentException` - An error has occurred during Document Library execution.

Copyright © 2020-2030, id3 Technologies. All rights reserved. eu.id3.document