MediaPipeTasksCommon Framework Reference

MPImage

final class MPImage: Sendable

Input image container for on-device MediaPipe Vision Tasks inference.

MPImage is @unchecked Sendable because all stored properties are let constants and its wrapped UIImage, CVPixelBuffer, and CMSampleBuffer instances are accessed strictly as read-only pixel sources during C MpImage conversion.

  • Creates an image from single-channel VEC32F1 pixel data.

    Declaration

    Swift

    init(floatData: [Float], width: Int, height: Int) throws
  • Creates an image from a 32BGRA or OneComponent32Float pixel buffer.

    Declaration

    Swift

    init(pixelBuffer: CVPixelBuffer, orientation: UIImage.Orientation = .up) throws
  • Creates an image from 4-channel RGBA pixel data.

    Declaration

    Swift

    init(rgbaData: [UInt8], width: Int, height: Int) throws
  • Creates an image from a sample buffer containing a CVImageBuffer.

    Declaration

    Swift

    init(sampleBuffer: CMSampleBuffer, orientation: UIImage.Orientation = .up) throws
  • Creates an image from uiImage, defaulting orientation to uiImage.imageOrientation.

    Declaration

    Swift

    init(uiImage: UIImage, orientation: UIImage.Orientation? = nil) throws
  • The single-channel VEC32F1 pixel buffer when initialized via init(floatData:width:height:), or nil otherwise.

    Declaration

    Swift

    final var floatData: [Float]? { get }
  • Height of the image in pixels.

    Declaration

    Swift

    final let height: CGFloat
  • The underlying UIImage when imageSourceType == .image, or nil otherwise.

    Declaration

    Swift

    final var image: UIImage? { get }
  • Underlying pixel storage representation.

    Declaration

    Swift

    final let imageSourceType: MPImageSourceType
  • Display orientation of the image.

    Declaration

    Swift

    final let orientation: UIImage.Orientation
  • The underlying CVPixelBuffer when imageSourceType == .pixelBuffer, or nil otherwise.

    Declaration

    Swift

    final var pixelBuffer: CVPixelBuffer? { get }
  • The 4-channel RGBA pixel buffer when initialized via init(rgbaData:width:height:), or nil otherwise.

    Declaration

    Swift

    final var rgbaData: [UInt8]? { get }
  • The underlying CMSampleBuffer when imageSourceType == .sampleBuffer, or nil otherwise.

    Declaration

    Swift

    final var sampleBuffer: CMSampleBuffer? { get }
  • Width of the image in pixels.

    Declaration

    Swift

    final let width: CGFloat