AI-generated Key Takeaways
-
VisionImageis an object used for vision detection tasks, accepting images or image buffers as input. -
It's crucial to set the
imageOrientationproperty of inputUIImageto.upbefore initialization to ensure proper orientation. -
When using
CMSampleBufferReffor initialization, ensure it's a pixel buffer with a supported pixel format likekCVPixelFormatType_32BGRAfor optimal performance. -
For
CMSampleBufferRefinputs, compatibility is primarily with phone camera output, not arbitrary buffer sources. -
Direct initialization using
init()is unavailable; utilizeinit(image:)orinit(buffer:)instead.
VisionImage
class VisionImage : NSObject, MLKitCompatibleImageAn image or image buffer used for vision detection.
-
The display orientation of the image. The default is
.up.Declaration
Swift
var orientation: Int32 { get set } -
Initializes a
VisionImageobject with the given image.Declaration
Swift
init(image: Any!)Parameters
imageImage to use in vision detection. The given image should be rotated, so its
imageOrientationproperty is set to.up. TheUIImagemust have non-NULLCGImageproperty.Return Value
A
VisionImageinstance with the given image. -
Initializes a
VisionImageobject with the given image buffer. To improve performance, it is recommended to minimize the lifespan and number of instances of this class when initializing with aCMSampleBufferRef.Declaration
Swift
init(buffer sampleBuffer: CMSampleBuffer)Parameters
sampleBufferImage buffer to use in vision detection. The buffer must be based on a pixel buffer (not compressed data), and the pixel format must be one of: -
kCVPixelFormatType_32BGRA-kCVPixelFormatType_420YpCbCr8BiPlanarFullRange-kCVPixelFormatType_420YpCbCr8BiPlanarVideoRangeIn practice: this works with the video output of the phone’s camera, but not other arbitrary sources ofCMSampleBufferRefs.Return Value
A
VisionImageinstance with the given image buffer. -
Unavailable.