FaceRecognizerSF
import { FaceRecognizerSF } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Native object: release it with using or delete(). Factories can return null; check before calling methods.
DNN-based face recognizer
model download link: https://github.com/opencv/opencv_zoo/tree/master/models/face_recognition_sface
Constructors and members
static create
Creates an instance of this class with given parameters
create(model: EmbindString, config: EmbindString, backend_id: number, target_id: number): FaceRecognizerSF | null;3 available overloads
create(model: EmbindString, config: EmbindString): FaceRecognizerSF | null;create(model: EmbindString, config: EmbindString, backend_id: number): FaceRecognizerSF | null;create(model: EmbindString, config: EmbindString, backend_id: number, target_id: number): FaceRecognizerSF | null;modelthe path of the onnx model used for face recognition
configthe path to the config file for compatibility, which is not requested for ONNX models
backend_idthe id of backend
target_idthe id of target device
The FaceRecognizerSF | null result.
static create1
Creates an instance of this class from a buffer containing the model weights and configuration.
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, backend_id: number, target_id: number): FaceRecognizerSF | null;3 available overloads
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector): FaceRecognizerSF | null;create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, backend_id: number): FaceRecognizerSF | null;create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, backend_id: number, target_id: number): FaceRecognizerSF | null;frameworkName of the framework (ONNX, etc.)
bufferModelA buffer containing the binary model weights.
bufferConfigA buffer containing the network configuration.
backend_idThe id of the backend.
target_idThe id of the target device.
A pointer to the created instance of FaceRecognizerSF.
clone
Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.
clone(): this;The this result.
alignCrop
Aligns detected face with the source input image and crops it
alignCrop(src_img: Mat, face_box: Mat, aligned_img: Mat): void;src_imginput image
face_boxthe detected face result from the input image
aligned_imgOutput destination, filled by the native operation. output aligned image
feature
Extracts face feature from aligned image
feature(aligned_img: Mat, face_feature: Mat): void;aligned_imginput aligned image
face_featureOutput destination, filled by the native operation. output face feature
match
Calculates the distance between two face features
match(face_feature1: Mat, face_feature2: Mat, dis_type: number): number;2 available overloads
match(face_feature1: Mat, face_feature2: Mat): number;match(face_feature1: Mat, face_feature2: Mat, dis_type: number): number;face_feature1the first input feature
face_feature2the second input feature of the same size and the same type as face_feature1
dis_typedefines how to calculate the distance between two face features with optional values "FR_COSINE" or "FR_NORM_L2"
The number result.
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.