MLKSegmenter
@interface MLKSegmenter : NSObject
對輸入圖片執行區隔的偵測工具。
-
傳回包含指定選項的區隔器。
聲明
Objective-C
+ (nonnull instancetype)segmenterWithOptions: (nonnull MLKCommonSegmenterOptions *)options;
參數
options
區隔設定選項。
傳回值
採用指定選項設定的區隔器。
-
無法使用,使用類別方法。
聲明
Objective-C
- (nonnull instancetype)init;
-
處理指定圖片進行區隔。
聲明
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKSegmentationCallback)completion;
參數
image
要處理的圖片。
completion
使用區隔遮罩或錯誤在主執行緒上回呼的處理常式。
-
傳回指定圖片中的區隔遮罩;如果發生錯誤,則傳回
nil
。區隔會在呼叫執行緒上同步執行。建議您從主執行緒呼叫此方法,以免封鎖 UI。因此,如果在主執行緒上呼叫此方法,就會引發
NSException
。聲明
Objective-C
- (nullable MLKSegmentationMask *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;
參數
image
要用於取得結果的圖片。
error
取得結果時發生錯誤時填入的選用錯誤參數。
傳回值
指定圖片中的區隔遮罩,如果發生錯誤,則為
nil
。