MPImage
class MPImage : NSObjectAn image used in on-device machine learning using MediaPipe Task library.
- 
                  
                  Width of the image in pixels. DeclarationSwift var width: CGFloat { get }
- 
                  
                  Height of the image in pixels. DeclarationSwift var height: CGFloat { get }
- 
                  
                  The display orientation of the image. If imageSourceTypeis.image, the default value isimage.imageOrientation; otherwise the default value isUIImage.Orientation.up. If theMPImageis being used as input for any MediaPipe vision tasks and is set to any orientation other thanUIImage.Orientation.up, inference will be performed on a rotated copy of the image according to the orientation.DeclarationSwift var orientation: UIImage.Orientation { get }
- 
                  
                  The type of the image source. DeclarationSwift var imageSourceType: MPImageSourceType { get }
- 
                  
                  The source image. nilifimageSourceTypeis not.image.DeclarationSwift var image: UIImage? { get }
- 
                  
                  The source pixel buffer. nilifimageSourceTypeis not.pixelBuffer.DeclarationSwift var pixelBuffer: CVPixelBuffer? { get }
- 
                  
                  The source sample buffer. nilifimageSourceTypeis not.sampleBuffer.DeclarationSwift var sampleBuffer: CMSampleBuffer? { get }
- 
                  
                  Initializes an MPImageobject with the givenUIImage.The orientation of the newly created MPImagewill be equal to theimageOrientationofUIImageand when sent to the vision tasks for inference, rotation will be applied accordingly. To create anMPImagewith an orientation different from itsimageOrientation, please useMPImage(uiImage:orientation:)s.DeclarationSwift convenience init(uiImage image: UIImage) throwsParametersimageThe image to use as the source. Its CGImageproperty must not beNULL.errorAn optional error parameter populated when there is an error in initializing the MPImage.Return ValueA new MPImageinstance with the given image as the source.nilif the givenimageisnilor invalid.
- 
                  
                  Initializes an MPImageobject with the givenUIImageand orientation.The given orientation will be used to calculate the rotation to be applied to the UIImagebefore inference is performed on it by the vision tasks. TheimageOrientationstored in theUIImageis ignored whenMPImageobjects created by this method are sent to the vision tasks for inference. UseMPImage(uiImage:)to initialize images with theimageOrientationofUIImage.If the newly created MPImageis used as input for any MediaPipe vision tasks, inference will be performed on a copy of the image rotated according to the orientation.DeclarationSwift init(uiImage image: UIImage, orientation: UIImage.Orientation) throwsParametersimageThe image to use as the source. Its CGImageproperty must not beNULL.orientationThe display orientation of the image. This will be stored in the property orientationMPImageand will override theimageOrientationof the passed inUIImage.errorAn optional error parameter populated when there is an error in initializing the MPImage.Return ValueA new MPImageinstance with the given image as the source.nilif the givenimageisnilor invalid.
- 
                  
                  Initializes an MPImageobject with the given pixel buffer.The orientation of the newly created MPImagewill beUIImageOrientationUp. Hence, if this image is used as input for any MediaPipe vision tasks, inference will be performed on the it without any rotation. To create anMPImagewith a different orientation, please useMPImage(pixelBuffer:orientation:).DeclarationSwift convenience init(pixelBuffer: CVPixelBuffer) throwsParameterspixelBufferThe pixel buffer to use as the source. It will be retained by the new MPImageinstance for the duration of its lifecycle.errorAn optional error parameter populated when there is an error in initializing the MPImage.Return ValueA new MPImageinstance with the given pixel buffer as the source.nilif the given pixel buffer isnilor invalid.
- 
                  
                  Initializes an MPImageobject with the given pixel buffer and orientation.If the newly created MPImageis used as input for any MediaPipe vision tasks, inference will be performed on a copy of the image rotated according to the orientation.DeclarationSwift init(pixelBuffer: CVPixelBuffer, orientation: UIImage.Orientation) throwsParameterspixelBufferThe pixel buffer to use as the source. It will be retained by the new MPImageinstance for the duration of its lifecycle.orientationThe display orientation of the image. errorAn optional error parameter populated when there is an error in initializing the MPImage.Return ValueA new MPImageinstance with the given orientation and pixel buffer as the source.nilif the given pixel buffer isnilor invalid.
- 
                  
                  Initializes an MPImageobject with the given sample buffer.The orientation of the newly created MPImagewill beUIImageOrientationUp. Hence, if this image is used as input for any MediaPipe vision tasks, inference will be performed on the it without any rotation. To create anMPImagewith a different orientation, please useMPImage(sampleBuffer:orientation:).DeclarationSwift convenience init(sampleBuffer: CMSampleBuffer) throwsParameterssampleBufferThe sample buffer to use as the source. It will be retained by the new MPImageinstance for the duration of its lifecycle. The sample buffer must be based on a pixel buffer (not compressed data). In practice, it should be the video output of the camera on an iOS device, not other arbitrary types ofCMSampleBuffers.Return ValueA new MPImageinstance with the given sample buffer as the source.nilif the given sample buffer isnilor invalid.
- 
                  
                  Initializes an MPImageobject with the given sample buffer and orientation.If the newly created MPImageis used as input for any MediaPipe vision tasks, inference will be performed on a copy of the image rotated according to the orientation.DeclarationSwift init(sampleBuffer: CMSampleBuffer, orientation: UIImage.Orientation) throwsParameterssampleBufferThe sample buffer to use as the source. It will be retained by the new MPImageinstance for the duration of its lifecycle. The sample buffer must be based on a pixel buffer (not compressed data). In practice, it should be the video output of the camera on an iOS device, not other arbitrary types ofCMSampleBuffers.orientationThe display orientation of the image. Return ValueA new MPImageinstance with the given orientation and sample buffer as the source.nilif the given sample buffer isnilor invalid.
- 
                  
                  Unavailable. 
- 
                  
                  Undocumented