Skip to main content
Version: 0.10.0

Function: createObjectDetector()

createObjectDetector<F, L>(config, runtime?): Promise<ObjectDetector<F, L>>

Defined in: extensions/cv/tasks/objectDetection.ts:141

Creates an object detector runner for executing local Object Detection models.

It validates the model inputs and outputs requirements, pre-allocates the necessary static execution tensors (boxes, scores, classes), sets up an image preprocessor, and registers clean disposal hooks to clear all native memory.

Type Parameters

F

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

The bounding box format.

L

L

The type representing the class labels.

Parameters

config

ObjectDetectorModel<F, L>

Object detector task configuration containing path and options. See ObjectDetectorModel.

runtime?

any

Optional worklet runtime thread on which to run the model execution.

Returns

Promise<ObjectDetector<F, L>>

A promise resolving to the instantiated ObjectDetector runner.

Throws

With code LOAD_FAILED if model fails to load, or SCHEMA_MISMATCH if model schema does not match object detection spec.