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
。细分 在发起调用的线程上同步执行。建议在主线程之外调用此方法,以避免阻塞界面。作为 结果,如果在主线程上调用此方法,则会引发
NSException
。声明
Objective-C
- (nullable MLKSegmentationMask *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;
参数
image
要获取结果的图片。
error
在获取结果时出错时填充的可选错误参数。
返回值
给定图片中的分割掩码或
nil
(如果出现错误)。