# MLKitVision Framework Reference

# GMLImage


    @interface GMLImage : NSObject

An image used in on-device machine learning.
- `


  ### [width](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)width)


  ` Width of the image in pixels.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly) CGFloat width;

- `


  ### [height](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)height)


  ` Height of the image in pixels.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly) CGFloat height;

- `


  ### [orientation](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)orientation)


  ` The display orientation of the image. If `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType` is `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)image`, the default value is
  `image.imageOrientation`; otherwise the default value is `.up`.

  #### Declaration

  Objective-C

      @property (nonatomic) int orientation;

- `


  ### [imageSourceType](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)imageSourceType)


  ` The type of the image source.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly) https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Type-Definitions.html#/c:GMLImage.h@T@GMLImageSourceType imageSourceType;

- `


  ### [image](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)image)


  ` The source image. `nil` if `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType` is not `.image`.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly, nullable) int *image;

- `


  ### [pixelBuffer](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)pixelBuffer)


  ` The source pixel buffer. `nil` if `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType` is not `.pixelBuffer`.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly, nullable) CVPixelBufferRef pixelBuffer;

- `


  ### [sampleBuffer](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(py)sampleBuffer)


  ` The source sample buffer. `nil` if `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)imageSourceType` is not `.sampleBuffer`.

  #### Declaration

  Objective-C

      @property (nonatomic, readonly, nullable) CMSampleBufferRef sampleBuffer;

- `


  ### [-initWithImage:](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(im)initWithImage:)


  ` 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 `https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage.html#/c:objc(cs)GMLImage(py)image`
  is `nil` or invalid.
- `


  ### [-initWithPixelBuffer:](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(im)initWithPixelBuffer:)


  ` 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.
- `


  ### [-initWithSampleBuffer:](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(im)initWithSampleBuffer:)


  ` 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 `CMSampleBuffer`s. |

  #### Return Value

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


  ### [-init](https://developers.google.com/ml-kit/reference/ios/mlkitvision/api/reference/Classes/GMLImage#/c:objc(cs)GMLImage(im)init)


  ` Unavailable.

  #### Declaration

  Objective-C

      - (nonnull instancetype)init;