Skip to main content
Version: Next

Interface: ObjectDetectionType<L>

Defined in: types/objectDetection.ts:77

Return type for the useObjectDetection hook. Manages the state and operations for Computer Vision object detection tasks.

Type Parameters

L

L extends LabelEnum

The LabelEnum representing the model's class labels.

Properties

downloadProgress

downloadProgress: number

Defined in: types/objectDetection.ts:96

Represents the download progress of the model binary as a value between 0 and 1.


error

error: RnExecutorchError | null

Defined in: types/objectDetection.ts:81

Contains the error object if the model failed to load, download, or encountered a runtime error during detection.


forward()

forward: (input, detectionThreshold?) => Promise<Detection<L>[]>

Defined in: types/objectDetection.ts:117

Executes the model's forward pass with automatic input type detection.

Parameters

input

Image source (string path/URI or PixelData object)

string | PixelData

detectionThreshold?

number

An optional number between 0 and 1 representing the minimum confidence score. Default is 0.7.

Returns

Promise<Detection<L>[]>

A Promise that resolves to an array of Detection objects.

Throws

If the model is not loaded or is currently processing another image.

Example

// String path
const detections1 = await model.forward('file:///path/to/image.jpg');

// Pixel data
const detections2 = await model.forward({
dataPtr: new Uint8Array(rgbPixels),
sizes: [480, 640, 3],
scalarType: ScalarType.BYTE
});

isGenerating

isGenerating: boolean

Defined in: types/objectDetection.ts:91

Indicates whether the model is currently processing an image.


isReady

isReady: boolean

Defined in: types/objectDetection.ts:86

Indicates whether the object detection model is loaded and ready to process images.


runOnFrame

runOnFrame: (frame, isFrontCamera, detectionThreshold) => Detection<L>[] | null

Defined in: types/objectDetection.ts:135

Synchronous worklet function for real-time VisionCamera frame processing. Automatically handles native buffer extraction and cleanup.

Use this for VisionCamera frame processing in worklets. For async processing, use forward() instead.

Available after model is loaded (isReady: true).

Param

VisionCamera Frame object

Param

Whether the front camera is active, used for mirroring corrections.

Param

The threshold for detection sensitivity.

Returns

Array of Detection objects representing detected items in the frame.