Package org.opencv.objdetect

## Class FaceRecognizerSF

- java.lang.Object
- - org.opencv.objdetect.FaceRecognizerSF

-     public class FaceRecognizerSF
      extends java.lang.Object

  DNN-based face recognizer model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_recognition_sface

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `FR_COSINE` |
    `static int` | `FR_NORM_L2` |
    `protected long` | `nativeObj` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `FaceRecognizerSF​(long addr)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static FaceRecognizerSF` | `__fromPtr__​(long addr)` |
    `void` | `alignCrop​(Mat src_img, Mat face_box, Mat aligned_img)` | Aligns detected face with the source input image and crops it
    `static FaceRecognizerSF` | `create​(java.lang.String model, java.lang.String config)` | Creates an instance of this class with given parameters
    `static FaceRecognizerSF` | `create​(java.lang.String model, java.lang.String config, int backend_id)` | Creates an instance of this class with given parameters
    `static FaceRecognizerSF` | `create​(java.lang.String model, java.lang.String config, int backend_id, int target_id)` | Creates an instance of this class with given parameters
    `static FaceRecognizerSF` | `create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig)` | Creates an instance of this class from a buffer containing the model weights and configuration.
    `static FaceRecognizerSF` | `create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, int backend_id)` | Creates an instance of this class from a buffer containing the model weights and configuration.
    `static FaceRecognizerSF` | `create​(java.lang.String framework, MatOfByte bufferModel, MatOfByte bufferConfig, int backend_id, int target_id)` | Creates an instance of this class from a buffer containing the model weights and configuration.
    `void` | `feature​(Mat aligned_img, Mat face_feature)` | Extracts face feature from aligned image
    `protected void` | `finalize()` |
    `long` | `getNativeObjAddr()` |
    `double` | `match​(Mat face_feature1, Mat face_feature2)` | Calculates the distance between two face features
    `double` | `match​(Mat face_feature1, Mat face_feature2, int dis_type)` | Calculates the distance between two face features

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### nativeObj

          protected final long nativeObj

    - #### FR_COSINE

          public static final int FR_COSINE

      See Also:
        Constant Field Values

    - #### FR_NORM_L2

          public static final int FR_NORM_L2

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FaceRecognizerSF

          protected FaceRecognizerSF​(long addr)

  - ### Method Detail

    - #### getNativeObjAddr

          public long getNativeObjAddr()

    - #### __fromPtr__

          public static FaceRecognizerSF __fromPtr__​(long addr)

    - #### alignCrop

          public void alignCrop​(Mat src_img,
                                Mat face_box,
                                Mat aligned_img)

      Aligns detected face with the source input image and crops it
      Parameters:
        `src_img` - input image
        `face_box` - the detected face result from the input image
        `aligned_img` - output aligned image

    - #### feature

          public void feature​(Mat aligned_img,
                              Mat face_feature)

      Extracts face feature from aligned image
      Parameters:
        `aligned_img` - input aligned image
        `face_feature` - output face feature

    - #### match

          public double match​(Mat face_feature1,
                              Mat face_feature2,
                              int dis_type)

      Calculates the distance between two face features
      Parameters:
        `face_feature1` - the first input feature
        `face_feature2` - the second input feature of the same size and the same type as face_feature1
        `dis_type` - defines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2"
      Returns:
        automatically generated

    - #### match

          public double match​(Mat face_feature1,
                              Mat face_feature2)

      Calculates the distance between two face features
      Parameters:
        `face_feature1` - the first input feature
        `face_feature2` - the second input feature of the same size and the same type as face_feature1
      Returns:
        automatically generated

    - #### create

          public static FaceRecognizerSF create​(java.lang.String model,
                                                java.lang.String config,
                                                int backend_id,
                                                int target_id)

      Creates an instance of this class with given parameters
      Parameters:
        `model` - the path of the onnx model used for face recognition
        `config` - the path to the config file for compability, which is not requested for ONNX models
        `backend_id` - the id of backend
        `target_id` - the id of target device
      Returns:
        automatically generated

    - #### create

          public static FaceRecognizerSF create​(java.lang.String model,
                                                java.lang.String config,
                                                int backend_id)

      Creates an instance of this class with given parameters
      Parameters:
        `model` - the path of the onnx model used for face recognition
        `config` - the path to the config file for compability, which is not requested for ONNX models
        `backend_id` - the id of backend
      Returns:
        automatically generated

    - #### create

          public static FaceRecognizerSF create​(java.lang.String model,
                                                java.lang.String config)

      Creates an instance of this class with given parameters
      Parameters:
        `model` - the path of the onnx model used for face recognition
        `config` - the path to the config file for compability, which is not requested for ONNX models
      Returns:
        automatically generated

    - #### create

          public static FaceRecognizerSF create​(java.lang.String framework,
                                                MatOfByte bufferModel,
                                                MatOfByte bufferConfig,
                                                int backend_id,
                                                int target_id)

      Creates an instance of this class from a buffer containing the model weights and configuration.
      Parameters:
        `framework` - Name of the framework (ONNX, etc.)
        `bufferModel` - A buffer containing the binary model weights.
        `bufferConfig` - A buffer containing the network configuration.
        `backend_id` - The id of the backend.
        `target_id` - The id of the target device.
      Returns:
        A pointer to the created instance of FaceRecognizerSF.

    - #### create

          public static FaceRecognizerSF create​(java.lang.String framework,
                                                MatOfByte bufferModel,
                                                MatOfByte bufferConfig,
                                                int backend_id)

      Creates an instance of this class from a buffer containing the model weights and configuration.
      Parameters:
        `framework` - Name of the framework (ONNX, etc.)
        `bufferModel` - A buffer containing the binary model weights.
        `bufferConfig` - A buffer containing the network configuration.
        `backend_id` - The id of the backend.
      Returns:
        A pointer to the created instance of FaceRecognizerSF.

    - #### create

          public static FaceRecognizerSF create​(java.lang.String framework,
                                                MatOfByte bufferModel,
                                                MatOfByte bufferConfig)

      Creates an instance of this class from a buffer containing the model weights and configuration.
      Parameters:
        `framework` - Name of the framework (ONNX, etc.)
        `bufferModel` - A buffer containing the binary model weights.
        `bufferConfig` - A buffer containing the network configuration.
      Returns:
        A pointer to the created instance of FaceRecognizerSF.

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`