Skip to main content
Version: 0.8.x

Interface: ObjectDetectionType<L>

Defined in: types/objectDetection.ts:116

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:135

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


error

error: RnExecutorchError | null

Defined in: types/objectDetection.ts:120

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


forward()

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

Defined in: types/objectDetection.ts:160

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

Parameters

input

Image source (string path/URI or PixelData object)

string | PixelData

options?

ObjectDetectionOptions<L>

Optional configuration for detection inference

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 with options
const detections1 = await model.forward('file:///path/to/image.jpg', {
detectionThreshold: 0.7,
inputSize: 640, // For YOLO models
classesOfInterest: ['PERSON', 'CAR']
});

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

getAvailableInputSizes()

getAvailableInputSizes: () => readonly number[] | undefined

Defined in: types/objectDetection.ts:174

Returns the available input sizes for multi-method models (e.g., YOLO). Returns undefined for single-method models (e.g., RF-DETR, SSDLite).

Returns

readonly number[] | undefined

Array of available input sizes or undefined

Example

const sizes = model.getAvailableInputSizes(); // [384, 512, 640] for YOLO models

isGenerating

isGenerating: boolean

Defined in: types/objectDetection.ts:130

Indicates whether the model is currently processing an image.


isReady

isReady: boolean

Defined in: types/objectDetection.ts:125

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


runOnFrame

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

Defined in: types/objectDetection.ts:189

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

Optional configuration for detection inference

Returns

Array of Detection objects representing detected items in the frame.