AI-generated Key Takeaways
-
MLKSegmenteris a detector that performs segmentation on input images. -
It provides methods for asynchronous and synchronous processing of images.
-
Segmentation results are provided as a
MLKSegmentationMaskobject. -
Users should avoid calling the synchronous method on the main thread to prevent UI blocking.
-
Initialization is done through a class method with
MLKCommonSegmenterOptions.
MLKSegmenter
@interface MLKSegmenter : NSObjectA detector that performs segmentation on input images.
-
Returns a segmenter with the given options.
Declaration
Objective-C
+ (nonnull instancetype)segmenterWithOptions: (nonnull MLKCommonSegmenterOptions *)options;Parameters
optionsOptions for configuring the segmenter.
Return Value
A segmenter configured with the given options.
-
Unavailable. Use the class methods.
Declaration
Objective-C
- (nonnull instancetype)init; -
Processes the given image for segmentation.
Declaration
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKSegmentationCallback)completion;Parameters
imageThe image to process.
completionHandler to call back on the main thread with the segmentation mask or error.
-
Returns the segmentation mask in the given image or
nilif there was an error. The segmentation is performed synchronously on the calling thread.It is advised to call this method off the main thread to avoid blocking the UI. As a result, an
NSExceptionis raised if this method is called on the main thread.Declaration
Objective-C
- (nullable MLKSegmentationMask *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;Parameters
imageThe image to get results in.
errorAn optional error parameter populated when there is an error getting results.
Return Value
The segmentation mask in the given image or
nilif there was an error.