# 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.
- `
  ### [init(floatData:width:height:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC9floatData5width6heightACSaySfG_S2itKcfc)

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

  #### Declaration

  Swift

      init(floatData: [Float], width: Int, height: Int) throws

- `
  ### [init(pixelBuffer:orientation:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC11pixelBuffer11orientationACSo11CVBufferRefa_So18UIImageOrientationVtKcfc)

  ` Creates an image from a `32BGRA` or `OneComponent32Float` pixel buffer.

  #### Declaration

  Swift

      init(pixelBuffer: CVPixelBuffer, orientation: UIImage.Orientation = .up) throws

- `
  ### [init(rgbaData:width:height:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC8rgbaData5width6heightACSays5UInt8VG_S2itKcfc)

  ` Creates an image from 4-channel RGBA pixel data.

  #### Declaration

  Swift

      init(rgbaData: [UInt8], width: Int, height: Int) throws

- `
  ### [init(sampleBuffer:orientation:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC12sampleBuffer11orientationACSo08CMSampleG3Refa_So18UIImageOrientationVtKcfc)

  ` Creates an image from a sample buffer containing a `CVImageBuffer`.

  #### Declaration

  Swift

      init(sampleBuffer: CMSampleBuffer, orientation: UIImage.Orientation = .up) throws

- `
  ### [init(uiImage:orientation:)](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC7uiImage11orientationACSo7UIImageC_So0I11OrientationVSgtKcfc)

  ` Creates an image from `uiImage`, defaulting `orientation` to `uiImage.imageOrientation`.

  #### Declaration

  Swift

      init(uiImage: UIImage, orientation: UIImage.Orientation? = nil) throws

- `
  ### [floatData](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC9floatDataSaySfGSgvp)

  ` The single-channel `VEC32F1` pixel buffer when initialized via `init(floatData:width:height:)`, or `nil` otherwise.

  #### Declaration

  Swift

      final var floatData: [Float]? { get }

- `
  ### [height](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC6height14CoreFoundation7CGFloatVvp)

  ` Height of the image in pixels.

  #### Declaration

  Swift

      final let height: CGFloat

- `
  ### [image](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC5imageSo7UIImageCSgvp)

  ` The underlying `UIImage` when `imageSourceType == .image`, or `nil` otherwise.

  #### Declaration

  Swift

      final var image: UIImage? { get }

- `
  ### [imageSourceType](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC15imageSourceTypeAA0egH0Ovp)

  ` Underlying pixel storage representation.

  #### Declaration

  Swift

      final let imageSourceType: MPImageSourceType

- `
  ### [orientation](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC11orientationSo18UIImageOrientationVvp)

  ` Display orientation of the image.

  #### Declaration

  Swift

      final let orientation: UIImage.Orientation

- `
  ### [pixelBuffer](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC11pixelBufferSo11CVBufferRefaSgvp)

  ` The underlying `CVPixelBuffer` when `imageSourceType == .pixelBuffer`, or `nil` otherwise.

  #### Declaration

  Swift

      final var pixelBuffer: CVPixelBuffer? { get }

- `
  ### [rgbaData](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC8rgbaDataSays5UInt8VGSgvp)

  ` The 4-channel RGBA pixel buffer when initialized via `init(rgbaData:width:height:)`, or `nil` otherwise.

  #### Declaration

  Swift

      final var rgbaData: [UInt8]? { get }

- `
  ### [sampleBuffer](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC12sampleBufferSo08CMSampleG3RefaSgvp)

  ` The underlying `CMSampleBuffer` when `imageSourceType == .sampleBuffer`, or `nil` otherwise.

  #### Declaration

  Swift

      final var sampleBuffer: CMSampleBuffer? { get }

- `
  ### [width](https://developers.google.com/edge/api/mediapipe/swift/common/Classes/MPImage.md.txt#/s:20MediaPipeTasksCommon7MPImageC5width14CoreFoundation7CGFloatVvp)

  ` Width of the image in pixels.

  #### Declaration

  Swift

      final let width: CGFloat