MLImage 框架参考文档

MLImage

class MLImage : NSObject

设备端机器学习中使用的图片。

  • 此图片的宽度,以像素为单位。

    声明

    Swift

    var width: CGFloat { get }
  • 图片的高度,以像素为单位。

    声明

    Swift

    var height: CGFloat { get }
  • 图片的显示方向。如果 imageSourceType.image,则默认值为 image.imageOrientation;否则,默认值为 .up

    声明

    Swift

    var orientation: Int32 { get set }
  • 图片来源的类型。

    声明

    Swift

    var imageSourceType: MLImageSourceType { get }
  • 来源映像。如果 imageSourceType 不为 .image,则为 nil

    声明

    Swift

    var image: UnsafeMutablePointer<Int32>? { get }
  • 源像素缓冲区。如果 imageSourceType 不为 .pixelBuffer,则为 nil

    声明

    Swift

    var pixelBuffer: CVPixelBuffer? { get }
  • 来源样本缓冲区。如果 imageSourceType 不为 .sampleBuffer,则为 nil

    声明

    Swift

    var sampleBuffer: CMSampleBuffer? { get }
  • 使用指定图片初始化 MLImage 对象。

    声明

    Swift

    init?(image: Any!)

    参数

    image

    要用作来源的图片。其 CGImage 属性不得为 NULL

    返回值

    使用指定映像作为来源的新 MLImage 实例。如果给定的 imagenil 或无效,则返回 nil

  • 使用指定的像素缓冲区初始化 MLImage 对象。

    声明

    Swift

    init?(pixelBuffer: CVPixelBuffer)

    参数

    pixelBuffer

    要用作源的像素缓冲区。新的 MLImage 实例将在其生命周期中保留该 ID。

    返回值

    以指定的像素缓冲区作为来源的新 MLImage 实例。如果给定的像素缓冲区为 nil 或无效,则返回 nil

  • 使用指定的样本缓冲区初始化 MLImage 对象。

    声明

    Swift

    init?(sampleBuffer: CMSampleBuffer)

    参数

    sampleBuffer

    要用作来源的样本缓冲区。新的 MLImage 实例将在其生命周期中保留该 ID。样本缓冲区必须基于像素缓冲区(而非压缩数据)。实际上,它应该是 iOS 设备上相机的视频输出,而不是其他任何类型的 CMSampleBuffer

    返回值

    以给定的样本缓冲区作为来源的新 MLImage 实例。如果给定的样本缓冲区为 nil 或无效,则返回 nil

  • 不可用。