.. index:: 
  !DocumentDetector.detectDocument Method
  
.. _id3_document_document_detector_detect_document_class_method:

===============================================================================
DocumentDetector.detectDocument Method
===============================================================================

Module: :ref:`DocumentDetector<id3_document_document_detector_class>`

Definition
----------

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.


.. tab-set::

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

      .. code:: Python

        detect_document(self, image: DocumentImage, detection_zone: Rectangle) -> DetectedDocument

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``detection_zone`` :ref:`Rectangle<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.


      **Returns**

        .. line-block::

          :ref:`DetectedDocument<id3_document_detected_document_class>`
          Detected document in the image

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Dart

        DetectedDocument detectDocument(DocumentImage image, Rectangle detectionZone)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``detectionZone`` :ref:`Rectangle<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.


      **Returns**

        .. line-block::

          :ref:`DetectedDocument<id3_document_detected_document_class>`
          Detected document in the image

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: C#

        public DetectedDocument DetectDocument(DocumentImage image, Rectangle detectionZone)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``detectionZone`` :ref:`Rectangle<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.


      **Returns**

        .. line-block::

          :ref:`DetectedDocument<id3_document_detected_document_class>`
          Detected document in the image

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Java

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

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``detectionZone`` :ref:`Rectangle<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.


      **Returns**

        .. line-block::

          :ref:`DetectedDocument<id3_document_detected_document_class>`
          Detected document in the image

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: Swift

        public func detectDocument(image: DocumentImage, detectionZone: Rectangle) throws -> DetectedDocument

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``detectionZone`` :ref:`Rectangle<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.


      **Returns**

        .. line-block::

          :ref:`DetectedDocument<id3_document_detected_document_class>`
          Detected document in the image

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


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

      .. code:: C

        int id3DocumentDetector_DetectDocument (
            ID3_DOCUMENT_DETECTOR hDocumentDetector, 
            ID3_DOCUMENT_IMAGE hImage, 
            const id3DocumentRectangle * sDetectionZone, 
            ID3_DETECTED_DOCUMENT hDetectedDocument)

      **Parameters**

        .. line-block::

          ``hDocumentDetector`` :ref:`ID3_DOCUMENT_DETECTOR<id3_document_document_detector_class>`
          :guilabel:`in` Handle to the DocumentDetector object.

          ``hImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` Source image to process

          ``sDetectionZone`` :ref:`const id3DocumentRectangle *<id3_document_rectangle_struct>`
          :guilabel:`in` Crop in the image where to look for document. Default is the full image. Output corners are in the full image referential.

          ``hDetectedDocument`` :ref:`ID3_DETECTED_DOCUMENT<id3_document_detected_document_class>`
          :guilabel:`out` Detected document in the image


      **Returns**

        .. line-block::

          ``int``
          An error code.
          See :ref:`id3DocumentError<id3_document_document_error_enum>` file for the list of possible error codes.


