<br />

Performs object detection on images.

**Signature:**

    export declare class ObjectDetector extends VisionTaskRunner 

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromOptions(wasmFileset, objectDetectorOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectorcreatefromoptions) | `static` | Initializes the Wasm runtime and creates a new object detector from the provided options. |
| [createFromModelBuffer(wasmFileset, modelAssetBuffer)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectorcreatefrommodelbuffer) | `static` | Initializes the Wasm runtime and creates a new object detector based on the provided model asset buffer. |
| [createFromModelPath(wasmFileset, modelAssetPath)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectorcreatefrommodelpath) | `static` | Initializes the Wasm runtime and creates a new object detector based on the path to the model asset. |
| [setOptions(options)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectorsetoptions) |   | Sets new options for the object detector. Calling `setOptions()` with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to `undefined`. |
| [detect(image, imageProcessingOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectordetect) |   | Performs object detection on the provided single image and waits synchronously for the response. Only use this method when the ObjectDetector is created with running mode `image`. |
| [detectForVideo(videoFrame, timestamp, imageProcessingOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.objectdetector#objectdetectordetectforvideo) |   | Performs object detection on the provided video frame and waits synchronously for the response. Only use this method when the ObjectDetector is created with running mode `video`. |

## ObjectDetector.createFromOptions() {#objectdetectorcreatefromoptions}

Initializes the Wasm runtime and creates a new object detector from the provided options.

**Signature:**

    static createFromOptions(wasmFileset: WasmFileset, objectDetectorOptions: ObjectDetectorOptions): Promise<ObjectDetector>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| objectDetectorOptions | ObjectDetectorOptions | The options for the Object Detector. Note that either a path to the model asset or a model buffer needs to be provided (via `baseOptions`). |

**Returns:**

Promise\<ObjectDetector\>

## ObjectDetector.createFromModelBuffer() {#objectdetectorcreatefrommodelbuffer}

Initializes the Wasm runtime and creates a new object detector based on the provided model asset buffer.

**Signature:**

    static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array | ReadableStreamDefaultReader): Promise<ObjectDetector>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array \| ReadableStreamDefaultReader | An array or a stream containing a binary representation of the model. |

**Returns:**

Promise\<ObjectDetector\>

## ObjectDetector.createFromModelPath() {#objectdetectorcreatefrommodelpath}

Initializes the Wasm runtime and creates a new object detector based on the path to the model asset.

**Signature:**

    static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ObjectDetector>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | string | The path to the model asset. |

**Returns:**

Promise\<ObjectDetector\>

## ObjectDetector.setOptions() {#objectdetectorsetoptions}

Sets new options for the object detector. Calling `setOptions()` with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to `undefined`.

**Signature:**

    setOptions(options: ObjectDetectorOptions): Promise<void>;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | ObjectDetectorOptions | The options for the object detector. |

**Returns:**

Promise\<void\>

## ObjectDetector.detect() {#objectdetectordetect}

Performs object detection on the provided single image and waits synchronously for the response. Only use this method when the ObjectDetector is created with running mode `image`.

**Signature:**

    detect(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| imageProcessingOptions | ImageProcessingOptions | the `ImageProcessingOptions` specifying how to process the input image before running inference. |

**Returns:**

DetectionResult

## ObjectDetector.detectForVideo() {#objectdetectordetectforvideo}

Performs object detection on the provided video frame and waits synchronously for the response. Only use this method when the ObjectDetector is created with running mode `video`.

**Signature:**

    detectForVideo(videoFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): DetectionResult;

### Parameters

| Parameter | Type | Description |
|---|---|---|
| videoFrame | ImageSource | A video frame to process. |
| timestamp | number | The timestamp of the current frame, in ms. |
| imageProcessingOptions | ImageProcessingOptions | the `ImageProcessingOptions` specifying how to process the input image before running inference. |

**Returns:**

DetectionResult