MLKObjectDetector
@interface MLKObjectDetector : NSObject
物件偵測工具和追蹤器,可偵測圖片中的物件,且支援追蹤它們。
-
傳回具有指定選項的物件偵測工具。
聲明
Objective-C
+ (nonnull instancetype)objectDetectorWithOptions: (nonnull MLKCommonObjectDetectorOptions *)options;
參數
options
設定物件偵測工具的選項。這應為
CommonObjectDetectorOptions
子類別的例項。傳回值
以指定選項設定的物件偵測工具。
-
無法使用,使用類別方法。
聲明
Objective-C
- (nonnull instancetype)init;
-
處理指定圖片,用於偵測及追蹤指定圖片。
聲明
Objective-C
- (void)processImage:(nonnull id<MLKCompatibleImage>)image completion:(nonnull MLKObjectDetectionCallback)completion;
參數
image
要處理的圖片。
completion
系統在主執行緒上偵測到物件或錯誤時用於回呼的處理常式。
-
傳回指定圖片中的物件結果,如果發生錯誤,則傳回
nil
。物件偵測作業會在呼叫執行緒上同步執行。建議您從主執行緒呼叫此方法,以免封鎖 UI。因此,如果在主執行緒上呼叫此方法,就會引發
NSException
。聲明
Objective-C
- (nullable NSArray<MLKObject *> *) resultsInImage:(nonnull id<MLKCompatibleImage>)image error:(NSError *_Nullable *_Nullable)error;
參數
image
要用於取得結果的圖片。
error
取得結果時發生錯誤時填入的選用錯誤參數。
傳回值
物件陣列會產生指定圖片,如果發生錯誤,則會產生
nil
。