Table of Contents

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

srcImg InputArray

input image

faceBox InputArray

the detected face result from the input image

alignedImg OutputArray

output 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

framework string

Name of the framework (ONNX, etc.)

bufferModel byte[]

A buffer containing the binary model weights.

bufferConfig byte[]

A buffer containing the network configuration.

backendId Backend

the id of backend

targetId Target

the id of target device

Returns

FaceRecognizerSF

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

model string

the path of the onnx model used for face recognition

config string

the path to the config file for compatibility, which is not requested for ONNX models

backendId Backend

the id of backend

targetId Target

the id of target device

Returns

FaceRecognizerSF

Feature(InputArray, OutputArray)

Extracts face feature from aligned image.

public void Feature(InputArray alignedImg, OutputArray faceFeature)

Parameters

alignedImg InputArray

input aligned image

faceFeature OutputArray

output 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

faceFeature1 InputArray

the first input feature

faceFeature2 InputArray

the second input feature of the same size and the same type as faceFeature1

disType FaceRecognizerSFDisType

defines how to calculate the distance between two face features

Returns

double