BUNDLEWARE

context.detectFaces

Context

Finds faces locally with YuNet, then fits a compact CPU CLM to estimate detailed landmarks. It is available independently of BrowseAnonymous.

Signaturecontext.detectFaces(image: string, options?: FaceOptions): Promise<readonly Face[]>
Take it fromconst { detectFaces } = useToolbar();

Parameters

ParameterTypeDescription
imagestringAn absolute HTTP(S) image URL without credentials, or a data:image/… URL. HTTP(S) URLs are limited to 4,096 characters. SVG images and blob: URLs are unsupported.
optionsFaceOptionsOptional. { signal?: AbortSignal }. Aborting stops this caller waiting and rejects with AbortError; the component's mount also bounds the call.

Return Value

A deeply read-only array of at most 32 faces. [] means no faces were detected; errors reject the promise.

TypePromise<readonly Face[]>

Face Geometry

All positions are fractions of the decoded image's width and height, independent of inference resizing.

FieldMeaning
x, y, width, heightFace box, normalized from 0 to 1.
scoreYuNet's face-detection confidence, from 0 to 1; not landmark confidence.
pointsMeasured rightEye, leftEye, nose, rightMouth, leftMouth, and the derived mouth midpoint. Right and left are the person's own: rightEye is on the viewer's left. Optional ear fields are absent with YuNet.
meshOptional accepted CLM fit: 66 points, 66 visibility flags, 91 fixed triangles of zero-based indices, and pose.pitch, pose.yaw, pose.roll in radians. Mesh points can extend outside a cropped image. Visibility describes the fitted view; hidden points are inferred.

Check mesh before using it. Faces smaller than 24 pixels across at inference size, weak image evidence or rejected fits retain only the detector landmarks. The fitted shape estimates lips, brows and jaw; it does not measure depth or trace the scalp.

The Faces guide lists every landmark region and explains how a toolbar maps the coordinates through CSS sizing and cropping. The API returns geometry; the toolbar owns drawing and cleanup.

Limits and Errors

The image download has a 20-second timeout and an 8 MiB file limit. Inference uses at most 640 pixels on the longer side and has a 30-second queue deadline. Small, occluded and strongly turned faces may be missed or have less accurate landmarks.

Invalid input rejects with TypeError; download, decode and worker failures reject with an error. An aborted signal or an ended mount rejects with AbortError, including an already-aborted signal. A worker failure clears pending detections; the next call starts a new worker.

Shared cache

One worker serves the toolbar owners, with an in-memory cache of the last 400 image results. Embedded-image keys are hashed; the cache retains geometry rather than image bytes. Cancelling a call stops that caller waiting while other callers can finish the shared work. Errors are not cached.

Availability

Bundleware1.0.1, build 2026.12.02
RuntimeBundled toolbars, imported Chrome user toolbars and the Editor's Preview on Page. The sandbox and website-only previews have no detector.
SetupIncluded with Bundleware, independent of the optional Gemini Nano language model.
NetworkNo @connect line is needed. Images download without cookies or referrer; pixels and detections are not uploaded. The WASM and both models ship in the extension.