Skip to main content
Version: 0.10.0

Function: useKeypointDetector()

useKeypointDetector<F, L>(config, options?): object

Defined in: hooks/useKeypointDetector.ts:28

React hook to load and run a keypoint detection model.

This hook manages downloading (if remote URLs are provided) and loading the model assets, compiling them, tracking download progress and load errors, and releasing native memory when the component unmounts or the configuration changes.

For imperative usage, see createKeypointDetector.

Type Parameters​

F​

F extends "xyxy" | "xywh" | "cxcywh"

The bounding box format.

L​

L extends PropertyKey

The landmark labels type.

Parameters​

config​

KeypointDetectorModel<F, L>

The keypoint detection model configuration. See KeypointDetectorModel.

options?​

ResourceOptions

Load and caching options. See ResourceOptions.

Returns​

object

The same object as KeypointDetector (without dispose), combined with loading state, download progress, and landmarks.

detectKeypoints​

detectKeypoints: (input, options?) => Promise<KeypointDetection<F, L>[]> | undefined = model.detectKeypoints

detectKeypointsWorklet​

detectKeypointsWorklet: (input, options?) => KeypointDetection<F, L>[] | undefined = model.detectKeypointsWorklet

downloadProgress​

downloadProgress: number

error​

error: Error | undefined

isReady​

isReady: boolean = !!model

landmarks​

landmarks: readonly L[] = config.modelOpts.landmarks

resource​

resource: KeypointDetectorModel<F, L> | undefined

See​

KeypointDetector