.. index:: 
  !DocumentDetector Class

.. _id3_document_document_detector_class:

===============================================================================
DocumentDetector Class
===============================================================================

Namespace: :ref:`id3.Document<reference_document>`

.. toctree::
  :hidden:

  alignDocument<align_document>
  confidenceThreshold<confidence_threshold>
  detectDocument<detect_document>
  detectDocumentByName<detect_document_by_name>
  documentWidthRatio<document_width_ratio>
  model<model>
  processingUnit<processing_unit>
  threadCount<thread_count>


Definition
----------
.. line-block::
    Detects documents in images.

.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

        class DocumentDetector

    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

        class DocumentDetector implements Finalizable

    .. tab-item:: C#
      :sync: C#

      .. code:: C#

        public partial class DocumentDetector

    .. tab-item:: Java
      :sync: Java

      .. code:: Java

        public class DocumentDetector implements AutoCloseable, Serializable

    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

        public class DocumentDetector

    .. tab-item:: C
      :sync: C

      .. code:: C

        typedef struct id3DocumentDetector *ID3_DOCUMENT_DETECTOR;



Usage
-----

.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

        documentDetectorInstance = DocumentDetector()
        # ...

      **Explicit destruction**

      .. code:: Python

        # ...
        del documentDetectorInstance

    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

        final documentDetectorInstance = sdk.DocumentDetector();
        // ...

      **Explicit destruction**

      .. code:: Dart

        // ...
        documentDetectorInstance.dispose()

    .. tab-item:: C#
      :sync: C#

      .. code:: C#

        using (var documentDetectorInstance = new DocumentDetector())
        {
           // ...
        }

      **Explicit destruction**

      .. code:: C#

        var documentDetectorInstance = new DocumentDetector()
        // ...
        documentDetectorInstance.Dispose()

    .. tab-item:: Java
      :sync: Java

      .. code:: Java

        try (DocumentDetector documentDetectorInstance = new DocumentDetector()) {
        // ...
        }

      **Explicit destruction**

      .. code:: Java

        DocumentDetector documentDetectorInstance = new DocumentDetector();
        // ...
        documentDetectorInstance.close();

    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

        private var documentDetectorInstance: DocumentDetector? = nil
        documentDetectorInstance = try DocumentDetector()

    .. tab-item:: C
      :sync: C

      .. code:: C

        ID3_DOCUMENT_DETECTOR hDocumentDetector{};
        int err = id3DocumentDetector_Initialize(&hDocumentDetector);
        if (err == ID3_SUCCESS) {
            // ...
            id3DocumentDetector_Dispose(&hDocumentDetector);
        }


Properties
----------

.. list-table:: 
  :width: 100%
  :widths: 30 5 65
  :header-rows: 1

  * - Name
    - Type
    - Description
  * - :ref:`confidenceThreshold<id3_document_document_detector_confidence_threshold_class_member>`
    - int
    - Confidence threshold, from 0 to 100+.
  * - :ref:`documentWidthRatio<id3_document_document_detector_document_width_ratio_class_member>`
    - float
    - Ratio of the estimated width of the searched document in the image.
  * - :ref:`model<id3_document_document_detector_model_class_member>`
    - :ref:`DocumentModel<id3_document_document_model_enum>`
    - Model to be used for document detection.
  * - :ref:`processingUnit<id3_document_document_detector_processing_unit_class_member>`
    - :ref:`ProcessingUnit<id3_document_processing_unit_enum>`
    - Processing unit where to run the detection process.
  * - :ref:`threadCount<id3_document_document_detector_thread_count_class_member>`
    - int
    - Number of threads to use for detection.

Methods
-------

.. list-table:: 
  :width: 100%
  :widths: 30 70
  :header-rows: 1

  * - Name
    - Description
  * - :ref:`alignDocument<id3_document_document_detector_align_document_class_method>`
    - Aligns and crops the specified document on the specified image and returns a new DocumentImage.
  * - :ref:`detectDocument<id3_document_document_detector_detect_document_class_method>`
    - Detects a document on a delimited area of the specified DocumentImage and returns a DetectedDocument.
  * - :ref:`detectDocumentByName<id3_document_document_detector_detect_document_by_name_class_method>`
    - Detects a document with specified name on a delimited area of the specified DocumentImage and returns a DetectedDocument.
