MLImage 架構參考資料

GMLImage


@interface GMLImage : NSObject

在裝置端機器學習中使用的圖片。

  • 圖片的寬度 (以像素為單位)。

    聲明

    Objective-C

    @property (nonatomic, readonly) CGFloat width;
  • 圖片的高度 (以像素為單位)。

    聲明

    Objective-C

    @property (nonatomic, readonly) CGFloat height;
  • 圖片的顯示方向。如果 imageSourceType.image,則預設值為 image.imageOrientation;否則預設值為 .up

    聲明

    Objective-C

    @property (nonatomic) int orientation;
  • 圖片來源的類型。

    聲明

    Objective-C

    @property (nonatomic, readonly) GMLImageSourceType imageSourceType;
  • 來源圖片。如果 imageSourceType 不是 .image,則為 nil

    聲明

    Objective-C

    @property (nonatomic, readonly, nullable) int *image;
  • 來源像素緩衝區。如果 imageSourceType 不是 .pixelBuffer,則為 nil

    聲明

    Objective-C

    @property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;
  • 來源樣本緩衝區。如果 imageSourceType 不是 .sampleBuffer,則為 nil

    聲明

    Objective-C

    @property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;
  • 使用指定圖片初始化 MLImage 物件。

    聲明

    Objective-C

    - (nullable instancetype)initWithImage:(id)image;

    參數

    image

    要做為來源的圖片。其 CGImage 屬性不得為 NULL

    傳回值

    以指定映像檔做為來源的新 MLImage 執行個體。如果指定的 imagenil 或無效,則為 nil

  • 使用指定像素緩衝區初始化 MLImage 物件。

    聲明

    Objective-C

    - (nullable instancetype)initWithPixelBuffer:
        (nonnull CVPixelBufferRef)pixelBuffer;

    參數

    pixelBuffer

    要做為來源使用的像素緩衝區。新的 MLImage 執行個體會在生命週期內保留該執行個體。

    傳回值

    具有指定像素緩衝區做為來源的新 MLImage 執行個體。如果指定的像素緩衝區為 nil 或無效,則為 nil

  • 使用指定範例緩衝區初始化 MLImage 物件。

    聲明

    Objective-C

    - (nullable instancetype)initWithSampleBuffer:
        (nonnull CMSampleBufferRef)sampleBuffer;

    參數

    sampleBuffer

    要做為來源的範例緩衝區。新的 MLImage 執行個體會在生命週期內保留該執行個體。樣本緩衝區必須根據像素緩衝區 (非壓縮資料)。實際上,這應該是 iOS 裝置上的相機視訊輸出內容,而不是其他類型的 CMSampleBuffer

    傳回值

    具有指定範例緩衝區做為來源的新 MLImage 執行個體。如果指定範例緩衝區為 nil 或無效,則為 nil

  • 無法使用,

    聲明

    Objective-C

    - (nonnull instancetype)init;