<br />

Performs interactive segmentation on images. Users can represent user interaction through `RegionOfInterest`, which gives a hint to InteractiveSegmenterLegacy to perform segmentation focusing on the given region of interest. The API expects a TFLite model with mandatory TFLite Model Metadata. Input tensor: (kTfLiteUInt8/kTfLiteFloat32) - image input of size `[batch x height x width x channels]`. - batch inference is not supported (`batch` is required to be 1). - RGB inputs is supported (`channels` is required to be 3). - if type is kTfLiteFloat32, NormalizationOptions are required to be attached to the metadata for input normalization. Output tensors: (kTfLiteUInt8/kTfLiteFloat32) - list of segmented masks. - if `output_type` is CATEGORY_MASK, uint8 Image, Image vector of size 1. - if `output_type` is CONFIDENCE_MASK, float32 Image list of size `channels`. - batch is always 1

**Signature:**

```typescript
export declare class InteractiveSegmenterLegacy extends VisionTaskRunner 
```

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [createFromOptions(wasmFileset, interactiveSegmenterLegacyOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacycreatefromoptions) | `static` | Initializes the Wasm runtime and creates a new interactive segmenter from the provided options. |
| [createFromModelBuffer(wasmFileset, modelAssetBuffer)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacycreatefrommodelbuffer) | `static` | Initializes the Wasm runtime and creates a new interactive segmenter based on the provided model asset buffer. |
| [createFromModelPath(wasmFileset, modelAssetPath)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacycreatefrommodelpath) | `static` | Initializes the Wasm runtime and creates a new interactive segmenter based on the path to the model asset. |
| [setOptions(options)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacysetoptions) |   | Sets new options for the interactive segmenter. 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`. |
| [segment(image, roi, callback)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacysegment) |   | Performs interactive segmentation on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. The `roi` parameter is used to represent a user's region of interest for segmentation. |
| [segment(image, roi, imageProcessingOptions, callback)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacysegment_1) |   | Performs interactive segmentation on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. The `roi` parameter is used to represent a user's region of interest for segmentation. The 'imageProcessingOptions' parameter can be used to specify the rotation to apply to the image before performing segmentation, by setting its 'rotationDegrees' field. Note that specifying a region-of-interest using the 'regionOfInterest' field is NOT supported and will result in an error. |
| [segment(image, roi)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacysegment_2) |   | Performs interactive segmentation on the provided video frame and returns the segmentation result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The `roi` parameter is used to represent a user's region of interest for segmentation. |
| [segment(image, roi, imageProcessingOptions)](https://developers.google.com/edge/api/mediapipe/js/tasks-vision.interactivesegmenterlegacy.md.txt#interactivesegmenterlegacysegment_3) |   | Performs interactive segmentation on the provided video frame and returns the segmentation result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The `roi` parameter is used to represent a user's region of interest for segmentation. The 'imageProcessingOptions' parameter can be used to specify the rotation to apply to the image before performing segmentation, by setting its 'rotationDegrees' field. Note that specifying a region-of-interest using the 'regionOfInterest' field is NOT supported and will result in an error. |

## InteractiveSegmenterLegacy.createFromOptions()

Initializes the Wasm runtime and creates a new interactive segmenter from the provided options.

**Signature:**

```typescript
static createFromOptions(wasmFileset: WasmFileset, interactiveSegmenterLegacyOptions: InteractiveSegmenterLegacyOptions): Promise<InteractiveSegmenterLegacy>;
```

### Parameters

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

**Returns:**

Promise\<InteractiveSegmenterLegacy\>

## InteractiveSegmenterLegacy.createFromModelBuffer()

Initializes the Wasm runtime and creates a new interactive segmenter based on the provided model asset buffer.

**Signature:**

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

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

## InteractiveSegmenterLegacy.createFromModelPath()

Initializes the Wasm runtime and creates a new interactive segmenter based on the path to the model asset.

**Signature:**

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

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

## InteractiveSegmenterLegacy.setOptions()

Sets new options for the interactive segmenter. 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: InteractiveSegmenterLegacyOptions): Promise<void>;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| options | InteractiveSegmenterLegacyOptions | The options for the interactive segmenter. |

**Returns:**

Promise\<void\>

## InteractiveSegmenterLegacy.segment()

Performs interactive segmentation on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. The `roi` parameter is used to represent a user's region of interest for segmentation.

**Signature:**

```typescript
segment(image: ImageSource, roi: RegionOfInterest, callback: InteractiveSegmenterLegacyCallback): void;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| roi | RegionOfInterest | The region of interest for segmentation. |
| callback | InteractiveSegmenterLegacyCallback | The callback that is invoked with the segmented masks. The lifetime of the returned data is only guaranteed for the duration of the callback. |

**Returns:**

void

## InteractiveSegmenterLegacy.segment()

Performs interactive segmentation on the provided single image and invokes the callback with the response. The method returns synchronously once the callback returns. The `roi` parameter is used to represent a user's region of interest for segmentation. The 'imageProcessingOptions' parameter can be used to specify the rotation to apply to the image before performing segmentation, by setting its 'rotationDegrees' field. Note that specifying a region-of-interest using the 'regionOfInterest' field is NOT supported and will result in an error.

**Signature:**

```typescript
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions, callback: InteractiveSegmenterLegacyCallback): void;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| roi | RegionOfInterest | The region of interest for segmentation. |
| imageProcessingOptions | ImageProcessingOptions | the `ImageProcessingOptions` specifying how to process the input image before running inference. |
| callback | InteractiveSegmenterLegacyCallback | The callback that is invoked with the segmented masks. The lifetime of the returned data is only guaranteed for the duration of the callback. |

**Returns:**

void

## InteractiveSegmenterLegacy.segment()

Performs interactive segmentation on the provided video frame and returns the segmentation result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The `roi` parameter is used to represent a user's region of interest for segmentation.

**Signature:**

```typescript
segment(image: ImageSource, roi: RegionOfInterest): InteractiveSegmenterLegacyResult;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| roi | RegionOfInterest | The region of interest for segmentation. |

**Returns:**

InteractiveSegmenterLegacyResult

## InteractiveSegmenterLegacy.segment()

Performs interactive segmentation on the provided video frame and returns the segmentation result. This method creates a copy of the resulting masks and should not be used in high-throughput applications. The `roi` parameter is used to represent a user's region of interest for segmentation. The 'imageProcessingOptions' parameter can be used to specify the rotation to apply to the image before performing segmentation, by setting its 'rotationDegrees' field. Note that specifying a region-of-interest using the 'regionOfInterest' field is NOT supported and will result in an error.

**Signature:**

```typescript
segment(image: ImageSource, roi: RegionOfInterest, imageProcessingOptions: ImageProcessingOptions): InteractiveSegmenterLegacyResult;
```

### Parameters

| Parameter | Type | Description |
|---|---|---|
| image | ImageSource | An image to process. |
| roi | RegionOfInterest | The region of interest for segmentation. |
| imageProcessingOptions | ImageProcessingOptions | the `ImageProcessingOptions` specifying how to process the input image before running inference. |

**Returns:**

InteractiveSegmenterLegacyResult