MPPInteractiveSegmenter
@interface MPPInteractiveSegmenter : NSObject@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 (batchis required to be 1).
- RGB and greyscale inputs are supported (channelsis 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_typeis CATEGORY_MASK, uint8 Image, Image vector of size 1.
- if output_typeis CONFIDENCE_MASK, float32 Image list of sizechannels.
- batch is always 1.
An example of such model can be found at: https://tfhub.dev/tensorflow/lite-model/deeplabv3/1/metadata/2
- 
                  
                  Get the category label list of the InteractiveSegmentercan 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.DeclarationObjective-C @property (nonatomic, readonly) NSArray<NSString *> *_Nonnull labels;
- 
                  
                  Creates a new instance of InteractiveSegmenterfrom an absolute path to a TensorFlow Lite model file stored locally on the device and the defaultInteractiveSegmenterOptions.DeclarationObjective-C - (nullable instancetype)initWithModelPath:(nonnull NSString *)modelPath error:(NSError *_Nullable *_Nullable)error;ParametersmodelPathAn absolute path to a TensorFlow Lite model file stored locally on the device. Return ValueA new instance of InteractiveSegmenterwith the given model path.nilif there is an error in initializing the interactive segmenter.
- 
                  
                  Creates a new instance of InteractiveSegmenterfrom the givenInteractiveSegmenterOptions.DeclarationObjective-C - (nullable instancetype)initWithOptions: (nonnull MPPInteractiveSegmenterOptions *)options error:(NSError *_Nullable *_Nullable)error;ParametersoptionsThe options of type InteractiveSegmenterOptionsto use for configuring theInteractiveSegmenter.Return ValueA new instance of InteractiveSegmenterwith the given options.nilif there is an error in initializing the interactive segmenter.
- 
                  
                  Performs segmentation on the provided MPPImage using the specified user’s region of interest. Rotation will be applied according to the orientationproperty of the providedMPImage.This method supports interactive segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type of.imageensure that the color space is RGB with an Alpha channel.DeclarationObjective-C - (nullable MPPInteractiveSegmenterResult *) segmentImage:(nonnull MPPImage *)image regionOfInterest:(nonnull MPPRegionOfInterest *)regionOfInterest error:(NSError *_Nullable *_Nullable)error;ParametersimageThe MPImageon which segmentation is to be performed.Return ValueAn InteractiveSegmenterResultthat contains the segmented masks.
- 
                  
                  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 orientationproperty of the providedMPImage.This method supports interactive segmentation of RGBA images. If your MPImagehas a source type of.pixelBufferor.sampleBuffer, the underlying pixel buffer must usekCVPixelFormatType_32BGRAas its pixel format.If your MPImagehas a source type ofimageensure that the color space is RGB with an Alpha channel.DeclarationObjective-C - (void)segmentImage:(nonnull MPPImage *)image regionOfInterest:(nonnull MPPRegionOfInterest *)regionOfInterest withCompletionHandler: (nonnull void (^)(MPPInteractiveSegmenterResult *_Nullable, NSError *_Nullable))completionHandler;ParametersimageThe MPImageon which segmentation is to be performed.completionHandlerA block to be invoked with the results of performing segmentation on the image. The block takes two arguments, the optional InteractiveSegmenterResultthat 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.
- 
                  
                  Undocumented DeclarationObjective-C - (instancetype)init NS_UNAVAILABLE;
- 
                  
                  Undocumented DeclarationObjective-C + (instancetype)new NS_UNAVAILABLE;