Skip to content

FaceRecognizerSF

objdetectclassOpenCV 5.0.0
import { FaceRecognizerSF } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSFaceRecognizerSF
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods.

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;
model

the path of the onnx model used for face recognition

config

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

backend_id

the id of backend

target_id

the id of target device

Returns

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;
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.

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;
Returns

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_img

input image

face_box

the detected face result from the input image

aligned_img

Output 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_img

input aligned image

face_feature

Output 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_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

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.