.. index:: 
  !FacePad.computeColorBasedScore Method
  
.. _id3_face_face_pad_compute_color_based_score_class_method:

===============================================================================
FacePad.computeColorBasedScore Method
===============================================================================

Module: :ref:`FacePad<id3_face_face_pad_class>`

Definition
----------

Computes the PAD score and confidence of a detected face using only the color image.

A high score means a high probability for the face to be bona-fide, hence not an attack. The minimum recommended score is 90.

A low confidence means that the quality of the image is not sufficient enough to take a decision. The minimum recommended confidence is 70.

.. warning:: A minimum IOD (64 pixels per default) for the detected face is required for this function, below this value it will output an error.

.. important:: Loading the ``FaceColorBasedPad`` model is required to use this function.


.. tab-set::

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

      .. code:: Python

        compute_color_based_score(self, image: Image, detected_face: DetectedFace) -> ColorBasedPadResult

      **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:`ColorBasedPadResult<id3_face_color_based_pad_result_struct>`
          The computed PAD result including score and confidence.

      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        ColorBasedPadResult computeColorBasedScore(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:`ColorBasedPadResult<id3_face_color_based_pad_result_struct>`
          The computed PAD result including score and confidence.

      **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 ColorBasedPadResult ComputeColorBasedScore(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:`ColorBasedPadResult<id3_face_color_based_pad_result_struct>`
          The computed PAD result including score and confidence.

      **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 ColorBasedPadResult computeColorBasedScore(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:`ColorBasedPadResult<id3_face_color_based_pad_result_struct>`
          The computed PAD result including score and confidence.

      **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 computeColorBasedScore(image: Image, detectedFace: DetectedFace) throws -> ColorBasedPadResult

      **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:`ColorBasedPadResult<id3_face_color_based_pad_result_struct>`
          The computed PAD result including score and confidence.

      **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 id3FacePad_ComputeColorBasedScore (
            ID3_FACE_PAD hFacePad, 
            ID3_FACE_IMAGE hImage, 
            ID3_DETECTED_FACE hDetectedFace, 
            id3FaceColorBasedPadResult * sColorBasedPadResult)

      **Parameters**

        .. line-block::

          ``hFacePad`` :ref:`ID3_FACE_PAD<id3_face_face_pad_class>`
          :guilabel:`in` Handle to the FacePad 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.

          ``sColorBasedPadResult`` :ref:`id3FaceColorBasedPadResult *<id3_face_color_based_pad_result_struct>`
          :guilabel:`out` The computed PAD result including score and confidence.


      **Returns**

        .. line-block::

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


