FIRVisionImage.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #import <CoreMedia/CoreMedia.h>
  2. #import <UIKit/UIKit.h>
  3. @class FIRVisionImageMetadata;
  4. NS_ASSUME_NONNULL_BEGIN
  5. /**
  6. * An image or image buffer used in vision detection, with optional metadata.
  7. */
  8. NS_SWIFT_NAME(VisionImage)
  9. @interface FIRVisionImage : NSObject
  10. /**
  11. * Metadata about the image (e.g. image orientation). If metadata is not specified, the default
  12. * metadata values are used.
  13. */
  14. @property(nonatomic, nullable) FIRVisionImageMetadata *metadata;
  15. /**
  16. * Initializes a VisionImage object with the given image.
  17. *
  18. * @param image Image to use in vision detection. The given image should be rotated, so its
  19. * `imageOrientation` property is set to `UIImageOrientationUp` value. The `UIImage` must have
  20. * non-NULL `CGImage` property.
  21. * @return A VisionImage instance with the given image.
  22. */
  23. - (instancetype)initWithImage:(UIImage *)image NS_DESIGNATED_INITIALIZER;
  24. /**
  25. * Initializes a VisionImage object with the given image buffer. To improve performance, it is
  26. * recommended to minimize the lifespan and number of instances of this class when initializing with
  27. * a `CMSampleBufferRef`.
  28. *
  29. * @param sampleBuffer Image buffer to use in vision detection. The buffer must be based on
  30. * a pixel buffer (not compressed data), and the pixel format must be one of:
  31. * - `kCVPixelFormatType_32BGRA`
  32. * - `kCVPixelFormatType_420YpCbCr8BiPlanarFullRange`
  33. * - `kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange`
  34. * In practice: this works with the video output of the phone's camera, but not other
  35. * arbitrary sources of `CMSampleBufferRef`s.
  36. * @return A VisionImage instance with the given image buffer.
  37. */
  38. - (instancetype)initWithBuffer:(CMSampleBufferRef)sampleBuffer NS_DESIGNATED_INITIALIZER;
  39. /**
  40. * Unavailable.
  41. */
  42. - (instancetype)init NS_UNAVAILABLE;
  43. @end
  44. NS_ASSUME_NONNULL_END