MLKVisionImage
@interface MLKVisionImage : NSObject <MLKCompatibleImage>
用於偵測視覺的圖片或圖片緩衝區。
-
圖片的顯示方向。預設為
.up
。聲明
Objective-C
@property (nonatomic) int orientation;
-
使用指定圖片初始化
VisionImage
物件。聲明
Objective-C
- (nonnull instancetype)initWithImage:(id)image;
參數
image
要在視覺偵測中使用的圖片。指定的圖片應旋轉,因此其
imageOrientation
屬性必須設為.up
。UIImage
必須有非空值的CGImage
屬性。傳回值
含有指定映像檔的
VisionImage
執行個體。 -
使用指定圖片緩衝區初始化
VisionImage
物件。為提升效能,建議您在使用CMSampleBufferRef
初始化時,盡量縮短這個類別的生命週期和數量。聲明
Objective-C
- (nonnull instancetype)initWithBuffer:(nonnull CMSampleBufferRef)sampleBuffer;
參數
sampleBuffer
要在視覺偵測中使用的圖片緩衝區。緩衝區必須以像素緩衝區 (非壓縮資料) 為基礎,且像素格式必須是下列其中一種: -
kCVPixelFormatType_32BGRA
-kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
-kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
實務上:這個方法適用於手機相機的視訊輸出,但不能用於其他CMSampleBufferRef
的任意來源。傳回值
具有指定圖片緩衝區的
VisionImage
執行個體。 -
無法使用,
聲明
Objective-C
- (nonnull instancetype)init;