.. index:: 
  !FaceEncoder.createTemplate Method
  
.. _id3_face_face_encoder_create_template_class_method:

===============================================================================
FaceEncoder.createTemplate Method
===============================================================================

Module: :ref:`FaceEncoder<id3_face_face_encoder_class>`

Definition
----------

Extracts the unique features of a detected face and store them in a FaceTemplate.

.. warning:: A minimum interocular distance (IOD) of 30 pixels for the detected face is required for this function, below this value it will output an error.

.. important:: Loading a ``FaceEncoder`` model is required to use this function.


.. tab-set::

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

      .. code:: Python

        create_template(self, image: Image, detected_face: DetectedFace) -> FaceTemplate

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``detected_face`` :ref:`DetectedFace<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.


      **Returns**

        .. line-block::

          :ref:`FaceTemplate<id3_face_face_template_class>`
          The generated face template.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Dart

        FaceTemplate createTemplate(Image image, DetectedFace detectedFace)

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``detectedFace`` :ref:`DetectedFace<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.


      **Returns**

        .. line-block::

          :ref:`FaceTemplate<id3_face_face_template_class>`
          The generated face template.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: C#

        public FaceTemplate CreateTemplate(Image image, DetectedFace detectedFace)

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``detectedFace`` :ref:`DetectedFace<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.


      **Returns**

        .. line-block::

          :ref:`FaceTemplate<id3_face_face_template_class>`
          The generated face template.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Java

        public FaceTemplate createTemplate(Image image, DetectedFace detectedFace) throws FaceException

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``detectedFace`` :ref:`DetectedFace<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.


      **Returns**

        .. line-block::

          :ref:`FaceTemplate<id3_face_face_template_class>`
          The generated face template.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: Swift

        public func createTemplate(image: Image, detectedFace: DetectedFace) throws -> FaceTemplate

      **Parameters**

        .. line-block::

          ``image`` :ref:`Image<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``detectedFace`` :ref:`DetectedFace<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.


      **Returns**

        .. line-block::

          :ref:`FaceTemplate<id3_face_face_template_class>`
          The generated face template.

      **Exceptions**

        .. line-block::

          :ref:`FaceException<id3_face_face_exception>`
          An error has occurred during Face Library execution.


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

      .. code:: C

        int id3FaceEncoder_CreateTemplate (
            ID3_FACE_ENCODER hFaceEncoder, 
            ID3_FACE_IMAGE hImage, 
            ID3_DETECTED_FACE hDetectedFace, 
            ID3_FACE_TEMPLATE hFaceTemplate)

      **Parameters**

        .. line-block::

          ``hFaceEncoder`` :ref:`ID3_FACE_ENCODER<id3_face_face_encoder_class>`
          :guilabel:`in` Handle to the FaceEncoder object.

          ``hImage`` :ref:`ID3_FACE_IMAGE<id3_face_image_class>`
          :guilabel:`in` Source image to process.

          ``hDetectedFace`` :ref:`ID3_DETECTED_FACE<id3_face_detected_face_class>`
          :guilabel:`in` Detected face to process.

          ``hFaceTemplate`` :ref:`ID3_FACE_TEMPLATE<id3_face_face_template_class>`
          :guilabel:`out` The generated face template.


      **Returns**

        .. line-block::

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


