@brief Class that performs interactive segmentation on images.
Users can represent user interaction through RegionOfInterest, which gives a hint to
InteractiveSegmenter 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 and greyscale inputs are supported (channels is required to be
1 or 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.
Get the category label list of the InteractiveSegmenter can recognize. For CATEGORY_MASK type,
the index in the category mask corresponds to the category in the label list. For CONFIDENCE_MASK
type, the output mask list at index corresponds to the category in the label list. If there is no
labelmap provided in the model file, empty array is returned.
Creates a new instance of InteractiveSegmenter from an absolute path to a TensorFlow Lite model
file stored locally on the device and the default InteractiveSegmenterOptions.
Performs segmentation on the provided MPPImage using the specified user’s region of interest.
Rotation will be applied according to the orientation property of the provided MPImage.
This method supports interactive segmentation of RGBA images. If your MPImage has a source type
of .pixelBuffer or .sampleBuffer, the underlying pixel buffer must use
kCVPixelFormatType_32BGRA as its pixel format.
If your MPImage has a source type of .image ensure that the color space is RGB with an Alpha
channel.
Performs segmentation on the provided MPPImage using the specified user’s region of interest and
invokes the given completion handler block with the response. The method returns synchronously
once the completion handler returns.
Rotation will be applied according to the orientation property of the provided MPImage.
This method supports interactive segmentation of RGBA images. If your MPImage has a source type
of .pixelBuffer or .sampleBuffer, the underlying pixel buffer must use
kCVPixelFormatType_32BGRA as its pixel format.
If your MPImage has a source type of image ensure that the color space is RGB with an Alpha
channel.
The MPImage on which segmentation is to be performed.
completionHandler
A block to be invoked with the results of performing segmentation on the
image. The block takes two arguments, the optional InteractiveSegmenterResult that contains the
segmented masks if the segmentation was successful and an optional error populated upon failure.
The lifetime of the returned masks is only guaranteed for the duration of the block.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-08 UTC."],[],[],null,["# MediaPipeTasksVision Framework Reference\n\nMPPInteractiveSegmenter\n=======================\n\n\n @interface MPPInteractiveSegmenter : NSObject\n\n@brief Class that performs interactive segmentation on images.\n\nUsers can represent user interaction through `RegionOfInterest`, which gives a hint to\n`InteractiveSegmenter` to perform segmentation focusing on the given region of interest.\n\nThe API expects a TFLite model with mandatory TFLite Model Metadata.\n\nInput tensor:\n(kTfLiteUInt8/kTfLiteFloat32)\n\n- image input of size `[batch x height x width x channels]`.\n- batch inference is not supported (`batch` is required to be 1).\n- RGB and greyscale inputs are supported (`channels` is required to be 1 or 3).\n- if type is kTfLiteFloat32, NormalizationOptions are required to be attached to the metadata for input normalization. Output tensors: (kTfLiteUInt8/kTfLiteFloat32)\n- list of segmented masks.\n- if `output_type` is CATEGORY_MASK, uint8 Image, Image vector of size 1.\n- if `output_type` is CONFIDENCE_MASK, float32 Image list of size `channels`.\n- batch is always 1.\n\nAn example of such model can be found at:\n\u003chttps://tfhub.dev/tensorflow/lite-model/deeplabv3/1/metadata/2\u003e\n- `\n ``\n ``\n `\n\n ### [labels](#/c:objc(cs)MPPInteractiveSegmenter(py)labels)\n\n `\n ` \n Get the category label list of the `InteractiveSegmenter` can recognize. For CATEGORY_MASK type,\n the index in the category mask corresponds to the category in the label list. For CONFIDENCE_MASK\n type, the output mask list at index corresponds to the category in the label list. If there is no\n labelmap provided in the model file, empty array is returned. \n\n #### Declaration\n\n Objective-C \n\n @property (nonatomic, readonly) NSArray\u003cNSString *\u003e *_Nonnull labels;\n\n- `\n ``\n ``\n `\n\n ### [-initWithModelPath:error:](#/c:objc(cs)MPPInteractiveSegmenter(im)initWithModelPath:error:)\n\n `\n ` \n Creates a new instance of `InteractiveSegmenter` from an absolute path to a TensorFlow Lite model\n file stored locally on the device and the default `InteractiveSegmenterOptions`. \n\n #### Declaration\n\n Objective-C \n\n - (nullable instancetype)initWithModelPath:(nonnull NSString *)modelPath\n error:(NSError *_Nullable *_Nullable)error;\n\n #### Parameters\n\n |-------------------|--------------------------------------------------------------------------------|\n | ` `*modelPath*` ` | An absolute path to a TensorFlow Lite model file stored locally on the device. |\n\n #### Return Value\n\n A new instance of `InteractiveSegmenter` with the given model path. `nil` if there is an\n error in initializing the interactive segmenter.\n- `\n ``\n ``\n `\n\n ### [-initWithOptions:error:](#/c:objc(cs)MPPInteractiveSegmenter(im)initWithOptions:error:)\n\n `\n ` \n Creates a new instance of `InteractiveSegmenter` from the given `InteractiveSegmenterOptions`. \n\n #### Declaration\n\n Objective-C \n\n - (nullable instancetype)initWithOptions:\n (nonnull ../Classes/MPPInteractiveSegmenterOptions.html *)options\n error:(NSError *_Nullable *_Nullable)error;\n\n #### Parameters\n\n |-----------------|------------------------------------------------------------------------------------------------------|\n | ` `*options*` ` | The options of type `InteractiveSegmenterOptions` to use for configuring the `InteractiveSegmenter`. |\n\n #### Return Value\n\n A new instance of `InteractiveSegmenter` with the given options. `nil` if there is an\n error in initializing the interactive segmenter.\n- `\n ``\n ``\n `\n\n ### [-segmentImage:regionOfInterest:error:](#/c:objc(cs)MPPInteractiveSegmenter(im)segmentImage:regionOfInterest:error:)\n\n `\n ` \n Performs segmentation on the provided MPPImage using the specified user's region of interest.\n Rotation will be applied according to the `orientation` property of the provided `MPImage`.\n\n This method supports interactive segmentation of RGBA images. If your `MPImage` has a source type\n of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must use\n `kCVPixelFormatType_32BGRA` as its pixel format.\n\n If your `MPImage` has a source type of `.image` ensure that the color space is RGB with an Alpha\n channel. \n\n #### Declaration\n\n Objective-C \n\n - (nullable ../Classes/MPPInteractiveSegmenterResult.html *)\n segmentImage:(nonnull ../Classes/MPPImage.html *)image\n regionOfInterest:(nonnull ../Classes/MPPRegionOfInterest.html *)regionOfInterest\n error:(NSError *_Nullable *_Nullable)error;\n\n #### Parameters\n\n |---------------|---------------------------------------------------------|\n | ` `*image*` ` | The `MPImage` on which segmentation is to be performed. |\n\n #### Return Value\n\n An `InteractiveSegmenterResult` that contains the segmented masks.\n- `\n ``\n ``\n `\n\n ### [-segmentImage:regionOfInterest:withCompletionHandler:](#/c:objc(cs)MPPInteractiveSegmenter(im)segmentImage:regionOfInterest:withCompletionHandler:)\n\n `\n ` \n Performs segmentation on the provided MPPImage using the specified user's region of interest and\n invokes the given completion handler block with the response. The method returns synchronously\n once the completion handler returns.\n\n Rotation will be applied according to the `orientation` property of the provided `MPImage`.\n\n This method supports interactive segmentation of RGBA images. If your `MPImage` has a source type\n of `.pixelBuffer` or `.sampleBuffer`, the underlying pixel buffer must use\n `kCVPixelFormatType_32BGRA` as its pixel format.\n\n If your `MPImage` has a source type of `image` ensure that the color space is RGB with an Alpha\n channel. \n\n #### Declaration\n\n Objective-C \n\n - (void)segmentImage:(nonnull ../Classes/MPPImage.html *)image\n regionOfInterest:(nonnull ../Classes/MPPRegionOfInterest.html *)regionOfInterest\n withCompletionHandler:\n (nonnull void (^)(../Classes/MPPInteractiveSegmenterResult.html *_Nullable,\n NSError *_Nullable))completionHandler;\n\n #### Parameters\n\n |---------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | ` `*image*` ` | The `MPImage` on which segmentation is to be performed. |\n | ` `*completionHandler*` ` | A block to be invoked with the results of performing segmentation on the image. The block takes two arguments, the optional `InteractiveSegmenterResult` that contains the segmented masks if the segmentation was successful and an optional error populated upon failure. The lifetime of the returned masks is only guaranteed for the duration of the block. |\n\n- `\n ``\n ``\n `\n\n ### [-init](#/c:objc(cs)MPPInteractiveSegmenter(im)init)\n\n `\n ` \n Undocumented \n\n #### Declaration\n\n Objective-C \n\n - (instancetype)init NS_UNAVAILABLE;\n\n- `\n ``\n ``\n `\n\n ### [+new](#/c:objc(cs)MPPInteractiveSegmenter(cm)new)\n\n `\n ` \n Undocumented \n\n #### Declaration\n\n Objective-C \n\n + (instancetype)new NS_UNAVAILABLE;"]]