.. index:: 
  !DocumentReader.extractFace Method
  
.. _id3_document_document_reader_extract_face_class_method:

===============================================================================
DocumentReader.extractFace Method
===============================================================================

Module: :ref:`DocumentReader<id3_document_document_reader_class>`

Definition
----------

Extracts a crop of the face in a document.


.. tab-set::

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

      .. code:: Python

        extract_face(self, image: DocumentImage, document_name: str) -> DocumentImage

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``document_name`` str
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The cropped image of the face.

      **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 extractFace(DocumentImage image, String? documentName)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The cropped image of the face.

      **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 ExtractFace(DocumentImage image, string documentName)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` string
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The cropped image of the face.

      **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 extractFace(DocumentImage image, String documentName) throws DocumentException

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The cropped image of the face.

      **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 extractFace(image: DocumentImage, documentName: String) throws -> DocumentImage

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`DocumentImage<id3_document_document_image_class>`
          The cropped image of the face.

      **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 id3DocumentReader_ExtractFace (
            ID3_DOCUMENT_READER hDocumentReader, 
            ID3_DOCUMENT_IMAGE hImage, 
            const char * documentName, 
            ID3_DOCUMENT_IMAGE hCroppedFace)

      **Parameters**

        .. line-block::

          ``hDocumentReader`` :ref:`ID3_DOCUMENT_READER<id3_document_document_reader_class>`
          :guilabel:`in` Handle to the DocumentReader object.

          ``hImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` const char *
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.

          ``hCroppedFace`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`out` The cropped image of the face.


      **Returns**

        .. line-block::

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


