MLImage Framework Reference

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 imageSourceType is .image, the default value is image.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. nil if imageSourceType is not .image.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) int *image;
  • The source pixel buffer. nil if imageSourceType is not .pixelBuffer.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;
  • The source sample buffer. nil if imageSourceType is not .sampleBuffer.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;
  • Initializes an MLImage object with the given image.

    Declaration

    Objective-C

    - (nullable instancetype)initWithImage:(id)image;

    Parameters

    image

    The image to use as the source. Its CGImage property must not be NULL.

    Return Value

    A new MLImage instance with the given image as the source. nil if the given image is nil or invalid.

  • Initializes an MLImage object with the given pixel buffer.

    Declaration

    Objective-C

    - (nullable instancetype)initWithPixelBuffer:
        (nonnull CVPixelBufferRef)pixelBuffer;

    Parameters

    pixelBuffer

    The pixel buffer to use as the source. It will be retained by the new MLImage instance for the duration of its lifecycle.

    Return Value

    A new MLImage instance with the given pixel buffer as the source. nil if the given pixel buffer is nil or invalid.

  • Initializes an MLImage object with the given sample buffer.

    Declaration

    Objective-C

    - (nullable instancetype)initWithSampleBuffer:
        (nonnull CMSampleBufferRef)sampleBuffer;

    Parameters

    sampleBuffer

    The sample buffer to use as the source. It will be retained by the new MLImage instance 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 of CMSampleBuffers.

    Return Value

    A new MLImage instance with the given sample buffer as the source. nil if the given sample buffer is nil or invalid.

  • Unavailable.

    Declaration

    Objective-C

    - (nonnull instancetype)init;