.. index:: 
  !DocumentDetector.alignDocument Method
  
.. _id3_document_document_detector_align_document_class_method:

===============================================================================
DocumentDetector.alignDocument Method
===============================================================================

Module: :ref:`DocumentDetector<id3_document_document_detector_class>`

Definition
----------

Aligns and crops the specified document on the specified image and returns a new DocumentImage.


.. tab-set::

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

      .. code:: Python

        align_document(self, source_image: DocumentImage, detected_document: DetectedDocument) -> DocumentImage

      **Parameters**

        .. line-block::

          ``source_image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``detected_document`` :ref:`DetectedDocument<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          Realigned and cropped image of the document.

      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        DocumentImage alignDocument(DocumentImage sourceImage, DetectedDocument detectedDocument)

      **Parameters**

        .. line-block::

          ``sourceImage`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``detectedDocument`` :ref:`DetectedDocument<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          Realigned and cropped image of the document.

      **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 DocumentImage AlignDocument(DocumentImage sourceImage, DetectedDocument detectedDocument)

      **Parameters**

        .. line-block::

          ``sourceImage`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``detectedDocument`` :ref:`DetectedDocument<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          Realigned and cropped image of the document.

      **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 DocumentImage alignDocument(DocumentImage sourceImage, DetectedDocument detectedDocument) throws DocumentException

      **Parameters**

        .. line-block::

          ``sourceImage`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``detectedDocument`` :ref:`DetectedDocument<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          Realigned and cropped image of the document.

      **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 alignDocument(sourceImage: DocumentImage, detectedDocument: DetectedDocument) throws -> DocumentImage

      **Parameters**

        .. line-block::

          ``sourceImage`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``detectedDocument`` :ref:`DetectedDocument<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          Realigned and cropped image of the document.

      **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_AlignDocument (
            ID3_DOCUMENT_DETECTOR hDocumentDetector, 
            ID3_DOCUMENT_IMAGE hSourceImage, 
            ID3_DETECTED_DOCUMENT hDetectedDocument, 
            ID3_DOCUMENT_IMAGE hAlignedImage)

      **Parameters**

        .. line-block::

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

          ``hSourceImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` The source image containing the document.

          ``hDetectedDocument`` :ref:`ID3_DETECTED_DOCUMENT<id3_document_detected_document_class>`
          :guilabel:`in` The detected document in the image.

          ``hAlignedImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`out` Realigned and cropped image of the document.


      **Returns**

        .. line-block::

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


