MPImage
final class MPImage: SendableInput 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
VEC32F1pixel data.Declaration
Swift
init(floatData: [Float], width: Int, height: Int) throws -
Creates an image from a
32BGRAorOneComponent32Floatpixel 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, defaultingorientationtouiImage.imageOrientation.Declaration
Swift
init(uiImage: UIImage, orientation: UIImage.Orientation? = nil) throws -
The single-channel
VEC32F1pixel buffer when initialized viainit(floatData:width:height:), ornilotherwise.Declaration
Swift
final var floatData: [Float]? { get } -
Height of the image in pixels.
Declaration
Swift
final let height: CGFloat -
The underlying
UIImagewhenimageSourceType == .image, ornilotherwise.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
CVPixelBufferwhenimageSourceType == .pixelBuffer, ornilotherwise.Declaration
Swift
final var pixelBuffer: CVPixelBuffer? { get } -
The 4-channel RGBA pixel buffer when initialized via
init(rgbaData:width:height:), ornilotherwise.Declaration
Swift
final var rgbaData: [UInt8]? { get } -
The underlying
CMSampleBufferwhenimageSourceType == .sampleBuffer, ornilotherwise.Declaration
Swift
final var sampleBuffer: CMSampleBuffer? { get } -
Width of the image in pixels.
Declaration
Swift
final let width: CGFloat