Page Summary
-
GMLImageis an object used for on-device machine learning representing an image. -
It can be initialized with an image, a pixel buffer, or a sample buffer, defining the image source.
-
GMLImageprovides read-only access to properties like width, height, orientation, and the image source type. -
If initialized with an image, the
imageproperty holds the source image; otherwise, it'snil. -
Similarly,
pixelBufferandsampleBufferproperties hold the respective source data depending on the initialization type, beingnilotherwise.
GMLImage
@interface
GMLImage
:
NSObject
An image used in on-device machine learning.
-
Width of the image in pixels.
Declaration
Objective-C
@property ( nonatomic , readonly ) CGFloat width ; -
Height of the image in pixels.
Declaration
Objective-C
@property ( nonatomic , readonly ) CGFloat height ; -
The display orientation of the image. If
imageSourceTypeis.image, the default value isimage.imageOrientation; otherwise the default value is.up.Declaration
Objective-C
@property ( nonatomic ) int orientation ; -
The type of the image source.
Declaration
Objective-C
@property ( nonatomic , readonly ) GMLImageSourceType imageSourceType ; -
The source image.
nilifimageSourceTypeis not.image.Declaration
Objective-C
@property ( nonatomic , readonly , nullable ) int * image ; -
The source pixel buffer.
nilifimageSourceTypeis not.pixelBuffer.Declaration
Objective-C
@property ( nonatomic , readonly , nullable ) CVPixelBufferRef pixelBuffer ; -
The source sample buffer.
nilifimageSourceTypeis not.sampleBuffer.Declaration
Objective-C
@property ( nonatomic , readonly , nullable ) CMSampleBufferRef sampleBuffer ; -
Initializes an
MLImageobject with the given image.Declaration
Objective-C
- ( nullable instancetype ) initWithImage :( id ) image ;Parameters
imageThe image to use as the source. Its
CGImageproperty must not beNULL.Return Value
A new
MLImageinstance with the given image as the source.nilif the givenimageisnilor invalid. -
Initializes an
MLImageobject with the given pixel buffer.Declaration
Objective-C
- ( nullable instancetype ) initWithPixelBuffer : ( nonnull CVPixelBufferRef ) pixelBuffer ;Parameters
pixelBufferThe pixel buffer to use as the source. It will be retained by the new
MLImageinstance for the duration of its lifecycle.Return Value
A new
MLImageinstance with the given pixel buffer as the source.nilif the given pixel buffer isnilor invalid. -
Initializes an
MLImageobject with the given sample buffer.Declaration
Objective-C
- ( nullable instancetype ) initWithSampleBuffer : ( nonnull CMSampleBufferRef ) sampleBuffer ;Parameters
sampleBufferThe sample buffer to use as the source. It will be retained by the new
MLImageinstance 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 Value
A new
MLImageinstance with the given sample buffer as the source.nilif the given sample buffer isnilor invalid. -
Unavailable.
Declaration
Objective-C
- ( nonnull instancetype ) init ;


