Skip to content

FaceDetectorYN

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

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

ARGUMENTSConstructor or factory
CLASSFaceDetectorYN
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 face detector class with given parameters

create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number, target_id: number): FaceDetectorYN | null;
6 available overloads
create(model: EmbindString, config: EmbindString, input_size: Size): FaceDetectorYN | null;
create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number): FaceDetectorYN | null;
create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number, nms_threshold: number): FaceDetectorYN | null;
create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number): FaceDetectorYN | null;
create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number): FaceDetectorYN | null;
create(model: EmbindString, config: EmbindString, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number, target_id: number): FaceDetectorYN | null;
model

the path to the requested model

config

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

input_size

the size of the input image

score_threshold

the threshold to filter out bounding boxes of score smaller than the given value

nms_threshold

the threshold to suppress bounding boxes of IoU bigger than the given value

top_k

keep top K bboxes before NMS

backend_id

the id of backend

target_id

the id of target device

Returns

The FaceDetectorYN | null result.

static create1

Creates an instance of face detector class with given parameters

create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number, target_id: number): FaceDetectorYN | null;
6 available overloads
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size): FaceDetectorYN | null;
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number): FaceDetectorYN | null;
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number, nms_threshold: number): FaceDetectorYN | null;
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number): FaceDetectorYN | null;
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number): FaceDetectorYN | null;
create1(framework: EmbindString, bufferModel: ucharVector, bufferConfig: ucharVector, input_size: Size, score_threshold: number, nms_threshold: number, top_k: number, backend_id: number, target_id: number): FaceDetectorYN | null;
framework

Name of origin framework

bufferModel

A buffer with a content of binary file with weights

bufferConfig

A buffer with a content of text file contains network configuration

input_size

the size of the input image

score_threshold

the threshold to filter out bounding boxes of score smaller than the given value

nms_threshold

the threshold to suppress bounding boxes of IoU bigger than the given value

top_k

keep top K bboxes before NMS

backend_id

the id of backend

target_id

the id of target device

Returns

The FaceDetectorYN | null result.

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.

setInputSize

Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model

setInputSize(input_size: Size): void;
input_size

the size of the input image

getInputSize

Read the input size.

Set the size for the network input, which overwrites the input size of creating model. Call this method when the size of input image does not match the input size when creating model

getInputSize(): Size;
Returns

The Size result.

setScoreThreshold

Set the score threshold to filter out bounding boxes of score less than the given value

setScoreThreshold(score_threshold: number): void;
score_threshold

threshold for filtering out bounding boxes

getScoreThreshold

Read the score threshold.

Set the score threshold to filter out bounding boxes of score less than the given value

getScoreThreshold(): number;
Returns

The number result.

setNMSThreshold

Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value

setNMSThreshold(nms_threshold: number): void;
nms_threshold

threshold for NMS operation

getNMSThreshold

Read the nmsthreshold.

Set the Non-maximum-suppression threshold to suppress bounding boxes that have IoU greater than the given value

getNMSThreshold(): number;
Returns

The number result.

setTopK

Set the number of bounding boxes preserved before NMS

setTopK(top_k: number): void;
top_k

the number of bounding boxes to preserve from top rank based on score

getTopK

Read the top k.

Set the number of bounding boxes preserved before NMS

getTopK(): number;
Returns

The number result.

detect

Detects faces in the input image. Following is an example output. image

detect(image: Mat, faces: Mat): number;
image

an image to detect

faces

Output destination, filled by the native operation. detection results stored in a 2D cv::Mat of shape [num_faces, 15]

  • 0-1: x, y of bbox top left corner
  • 2-3: width, height of bbox
  • 4-5: x, y of right eye (blue point in the example image)
  • 6-7: x, y of left eye (red point in the example image)
  • 8-9: x, y of nose tip (green point in the example image)
  • 10-11: x, y of right corner of mouth (pink point in the example image)
  • 12-13: x, y of left corner of mouth (yellow point in the example image)
  • 14: face score
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.