MLKitVision 框架参考

MLKVisionImage


@interface MLKVisionImage : NSObject <MLKCompatibleImage>

用于视觉检测的图片或图片缓冲区。

  • 图片的显示方向。默认值为 .up

    声明

    Objective-C

    @property (nonatomic) int orientation;
  • 使用给定图片初始化 VisionImage 对象。

    声明

    Objective-C

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

    参数

    image

    要在视觉检测中使用的图片。指定图片应旋转,因此其 imageOrientation 属性设置为 .upUIImage 必须具有非 NULL 值的 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;