| OpenCV 5.0.0alpha Open Source Computer Vision

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
cv::FaceRecognizerSF Class Referenceabstract
Object Detection » DNN-based face detection and recognition

DNN-based face recognizer. More...

`#include <opencv2/objdetect/face.hpp>`

Collaboration diagram for cv::FaceRecognizerSF:

## Public Types
enum | DisType { FR_COSINE =0 , FR_NORM_L2 =1 }
| Definition of distance used for calculating the distance between two face features. More...

## Public Member Functions
virtual | ~FaceRecognizerSF ()
virtual void | alignCrop (InputArray src_img, InputArray face_box, OutputArray aligned_img) const =0
| Aligns detected face with the source input image and crops it.
virtual void | feature (InputArray aligned_img, OutputArray face_feature)=0
| Extracts face feature from aligned image.
virtual double | match (InputArray face_feature1, InputArray face_feature2, int dis_type=FaceRecognizerSF::FR_COSINE) const =0
| Calculates the distance between two face features.

## Static Public Member Functions
static Ptr< FaceRecognizerSF > | create (const String &framework, const std::vector< uchar > &bufferModel, const std::vector< uchar > &bufferConfig, int backend_id=0, int target_id=0)
| Creates an instance of this class from a buffer containing the model weights and configuration.
static Ptr< FaceRecognizerSF > | create (CV_WRAP_FILE_PATH const String &model, CV_WRAP_FILE_PATH const String &config, int backend_id=0, int target_id=0)
| Creates an instance of this class with given parameters.

## Detailed Description

DNN-based face recognizer.

model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_recognition_sface

## Member Enumeration Documentation

## ◆ DisType

enum cv::FaceRecognizerSF::DisType

Definition of distance used for calculating the distance between two face features.

Enumerator
FR_COSINE |
FR_NORM_L2 |

## Constructor & Destructor Documentation

## ◆ ~FaceRecognizerSF()

virtual cv::FaceRecognizerSF::~FaceRecognizerSF | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ alignCrop()

virtual void cv::FaceRecognizerSF::alignCrop | ( | InputArray | src_img,
|  | InputArray | face_box,
|  | OutputArray | aligned_img ) const
| pure virtual

Python:
| cv.FaceRecognizerSF.alignCrop( | src_img, face_box[, aligned_img] | ) -> | 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

## ◆ create() [1/2]

static Ptr< FaceRecognizerSF > cv::FaceRecognizerSF::create | ( | const String & | framework,
|  | const std::vector< uchar > & | bufferModel,
|  | const std::vector< uchar > & | bufferConfig,
|  | int | backend_id = 0,
|  | int | target_id = 0 )
| static

Python:
| cv.FaceRecognizerSF.create( | model, config[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF.create( | framework, bufferModel, bufferConfig[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF_create( | model, config[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF_create( | framework, bufferModel, bufferConfig[, backend_id[, target_id]] | ) -> | retval

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() [2/2]

static Ptr< FaceRecognizerSF > cv::FaceRecognizerSF::create | ( | CV_WRAP_FILE_PATH const String & | model,
|  | CV_WRAP_FILE_PATH const String & | config,
|  | int | backend_id = 0,
|  | int | target_id = 0 )
| static

Python:
| cv.FaceRecognizerSF.create( | model, config[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF.create( | framework, bufferModel, bufferConfig[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF_create( | model, config[, backend_id[, target_id]] | ) -> | retval
| cv.FaceRecognizerSF_create( | framework, bufferModel, bufferConfig[, backend_id[, target_id]] | ) -> | retval

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

## ◆ feature()

virtual void cv::FaceRecognizerSF::feature | ( | InputArray | aligned_img,
|  | OutputArray | face_feature )
| pure virtual

Python:
| cv.FaceRecognizerSF.feature( | aligned_img[, face_feature] | ) -> | face_feature

Extracts face feature from aligned image.

Parameters

  aligned_img | input aligned image
  face_feature | output face feature

## ◆ match()

virtual double cv::FaceRecognizerSF::match | ( | InputArray | face_feature1,
|  | InputArray | face_feature2,
|  | int | dis_type = FaceRecognizerSF::FR_COSINE ) const
| pure virtual

Python:
| cv.FaceRecognizerSF.match( | face_feature1, face_feature2[, dis_type] | ) -> | retval

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"

The documentation for this class was generated from the following file:

- opencv2/objdetect/face.hpp