MLKitImageLabelingCommon 架構參考資料

ImageLabeler

class ImageLabeler : NSObject

處理圖片並加上標籤的圖片標籤人員。

  • 傳回具有指定選項的圖片標籤人員。

    聲明

    Swift

    class func imageLabeler(options: MLKCommonImageLabelerOptions) -> Self

    參數

    options

    圖片標籤工具設定選項。

    傳回值

    使用指定選項設定的圖片標籤工具。

  • 無法使用,使用類別方法。

  • 處理指定圖片要加上標籤。

    聲明

    Swift

    func process(_ image: MLKitCompatibleImage, completion: @escaping ImageLabelingCallback)

    參數

    image

    要處理的圖片。

    completion

    用於在主要佇列中傳回標籤或錯誤的處理常式。

  • 傳回指定圖片中的標籤結果;如果發生錯誤,則傳回 nil。系統會在呼叫執行緒上同步執行圖片標籤。

    建議您從主執行緒呼叫此方法,以免封鎖 UI。因此,如果在主執行緒上呼叫此方法,就會引發 NSException

    聲明

    Swift

    func results(in image: MLKitCompatibleImage) throws -> [MLKImageLabel]

    參數

    image

    要用於取得結果的圖片。

    error

    取得結果時發生錯誤時填入的選用錯誤參數。

    傳回值

    標籤陣列會產生指定圖片,如果發生錯誤,則會產生 nil