<br />

Performs embedding extraction on images.

**Signature:**

```typescript
export declare class ImageEmbedder extends VisionTaskRunner 
```

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromOptions(wasmFileset, imageEmbedderOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembeddercreatefromoptions) | `static` | Initializes the Wasm runtime and creates a new image embedder from the provided options. |
| [createFromModelBuffer(wasmFileset, modelAssetBuffer)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembeddercreatefrommodelbuffer) | `static` | Initializes the Wasm runtime and creates a new image embedder based on the provided model asset buffer. |
| [createFromModelPath(wasmFileset, modelAssetPath)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembeddercreatefrommodelpath) | `static` | Initializes the Wasm runtime and creates a new image embedder based on the path to the model asset. |
| [setOptions(options)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembeddersetoptions) |   | Sets new options for the image embedder. 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`. |
| [embed(image, imageProcessingOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembedderembed) |   | Performs embedding extraction on the provided single image and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode `image`. |
| [embedForVideo(imageFrame, timestamp, imageProcessingOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembedderembedforvideo) |   | Performs embedding extraction on the provided video frame and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode `video`. |
| [cosineSimilarity(u, v)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.imageembedder.md.txt#imageembeddercosinesimilarity) | `static` | Utility function to compute cosine similarity\[1\] between two `Embedding` objects. \[1\]: https://en.wikipedia.org/wiki/Cosine_similarity |

## ImageEmbedder.createFromOptions()

Initializes the Wasm runtime and creates a new image embedder from the provided options.

**Signature:**

```typescript
static createFromOptions(wasmFileset: WasmFileset, imageEmbedderOptions: ImageEmbedderOptions): Promise<ImageEmbedder>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| imageEmbedderOptions | ImageEmbedderOptions | The options for the image embedder. Note that either a path to the TFLite model or the model itself needs to be provided (via `baseOptions`). |

**Returns:**

Promise\<ImageEmbedder\>

## ImageEmbedder.createFromModelBuffer()

Initializes the Wasm runtime and creates a new image embedder based on the provided model asset buffer.

**Signature:**

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

### 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\<ImageEmbedder\>

## ImageEmbedder.createFromModelPath()

Initializes the Wasm runtime and creates a new image embedder based on the path to the model asset.

**Signature:**

```typescript
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<ImageEmbedder>;
```

### 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 TFLite model. |

**Returns:**

Promise\<ImageEmbedder\>

## ImageEmbedder.setOptions()

Sets new options for the image embedder. 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:**

```typescript
setOptions(options: ImageEmbedderOptions): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | ImageEmbedderOptions | The options for the image embedder. |

**Returns:**

Promise\<void\>

## ImageEmbedder.embed()

Performs embedding extraction on the provided single image and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode `image`.

**Signature:**

```typescript
embed(image: ImageSource, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
```

### Parameters

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

**Returns:**

ImageEmbedderResult

## ImageEmbedder.embedForVideo()

Performs embedding extraction on the provided video frame and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode `video`.

**Signature:**

```typescript
embedForVideo(imageFrame: ImageSource, timestamp: number, imageProcessingOptions?: ImageProcessingOptions): ImageEmbedderResult;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| imageFrame | ImageSource | The image 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:**

ImageEmbedderResult

## ImageEmbedder.cosineSimilarity()

Utility function to compute cosine similarity\[1\] between two `Embedding` objects. \[1\]: https://en.wikipedia.org/wiki/Cosine_similarity

**Signature:**

```typescript
static cosineSimilarity(u: Embedding, v: Embedding): number;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| u | Embedding |   |
| v | Embedding |   |

**Returns:**

number