Class FaceRecognizerSF
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
DNN-based face recognizer
public class FaceRecognizerSF : Algorithm, IDisposable
- Inheritance
-
FaceRecognizerSF
- Implements
- Inherited Members
Methods
AlignCrop(InputArray, InputArray, OutputArray)
Aligns detected face with the source input image and crops it.
public void AlignCrop(InputArray srcImg, InputArray faceBox, OutputArray alignedImg)
Parameters
srcImgInputArrayinput image
faceBoxInputArraythe detected face result from the input image
alignedImgOutputArrayoutput aligned image
Create(string, byte[], byte[], Backend, Target)
Creates an instance of this class from a buffer containing the model weights and configuration.
public static FaceRecognizerSF Create(string framework, byte[] bufferModel, byte[] bufferConfig, Backend backendId = Backend.DEFAULT, Target targetId = Target.CPU)
Parameters
frameworkstringName of the framework (ONNX, etc.)
bufferModelbyte[]A buffer containing the binary model weights.
bufferConfigbyte[]A buffer containing the network configuration.
backendIdBackendthe id of backend
targetIdTargetthe id of target device
Returns
Create(string, string, Backend, Target)
Creates an instance of this class with given parameters.
public static FaceRecognizerSF Create(string model, string config, Backend backendId = Backend.DEFAULT, Target targetId = Target.CPU)
Parameters
modelstringthe path of the onnx model used for face recognition
configstringthe path to the config file for compatibility, which is not requested for ONNX models
backendIdBackendthe id of backend
targetIdTargetthe id of target device
Returns
Feature(InputArray, OutputArray)
Extracts face feature from aligned image.
public void Feature(InputArray alignedImg, OutputArray faceFeature)
Parameters
alignedImgInputArrayinput aligned image
faceFeatureOutputArrayoutput face feature
Match(InputArray, InputArray, FaceRecognizerSFDisType)
Calculates the distance between two face features.
public double Match(InputArray faceFeature1, InputArray faceFeature2, FaceRecognizerSFDisType disType = FaceRecognizerSFDisType.Cosine)
Parameters
faceFeature1InputArraythe first input feature
faceFeature2InputArraythe second input feature of the same size and the same type as faceFeature1
disTypeFaceRecognizerSFDisTypedefines how to calculate the distance between two face features