MLImage
class MLImage : NSObject
An image used in on-device machine learning.
-
Width of the image in pixels.
Declaration
Swift
var width: CGFloat { get }
-
Height of the image in pixels.
Declaration
Swift
var height: CGFloat { get }
-
The display orientation of the image. If
imageSourceType
is.image
, the default value isimage.imageOrientation
; otherwise the default value is.up
.Declaration
Swift
var orientation: Int32 { get set }
-
The type of the image source.
Declaration
Swift
var imageSourceType: MLImageSourceType { get }
-
The source image.
nil
ifimageSourceType
is not.image
.Declaration
Swift
var image: UnsafeMutablePointer<Int32>? { get }
-
The source pixel buffer.
nil
ifimageSourceType
is not.pixelBuffer
.Declaration
Swift
var pixelBuffer: CVPixelBuffer? { get }
-
The source sample buffer.
nil
ifimageSourceType
is not.sampleBuffer
.Declaration
Swift
var sampleBuffer: CMSampleBuffer? { get }
-
Initializes an
MLImage
object with the given image.Declaration
Swift
init?(image: Any!)
Parameters
image
The image to use as the source. Its
CGImage
property must not beNULL
.Return Value
A new
MLImage
instance with the given image as the source.nil
if the givenimage
isnil
or invalid. -
Initializes an
MLImage
object with the given pixel buffer.Declaration
Swift
init?(pixelBuffer: CVPixelBuffer)
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 isnil
or invalid. -
Initializes an
MLImage
object with the given sample buffer.Declaration
Swift
init?(sampleBuffer: CMSampleBuffer)
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 ofCMSampleBuffer
s.Return Value
A new
MLImage
instance with the given sample buffer as the source.nil
if the given sample buffer isnil
or invalid. -
Unavailable.