FIRVisionFaceDetector.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #import <Foundation/Foundation.h>
  2. @class FIRVisionFace;
  3. @class FIRVisionImage;
  4. NS_ASSUME_NONNULL_BEGIN
  5. /**
  6. * A block containing an array of faces or `nil` if there's an error.
  7. *
  8. * @param faces Array of faces detected in the image or `nil` if there was an error.
  9. * @param error The error or `nil`.
  10. */
  11. typedef void (^FIRVisionFaceDetectionCallback)(NSArray<FIRVisionFace *> *_Nullable faces,
  12. NSError *_Nullable error)
  13. NS_SWIFT_NAME(VisionFaceDetectionCallback);
  14. /**
  15. * A face detector that detects faces in an image.
  16. */
  17. NS_SWIFT_NAME(VisionFaceDetector)
  18. @interface FIRVisionFaceDetector : NSObject
  19. /**
  20. * Unavailable. Use `Vision` factory methods.
  21. */
  22. - (instancetype)init NS_UNAVAILABLE;
  23. /**
  24. * Processes the given image for face detection. The detection is performed asynchronously and calls
  25. * back the completion handler with the detected face results or error on the main thread.
  26. *
  27. * @param image The vision image to use for detecting faces.
  28. * @param completion Handler to call back on the main thread with faces detected or error.
  29. */
  30. - (void)processImage:(FIRVisionImage *)image
  31. completion:(FIRVisionFaceDetectionCallback)completion
  32. NS_SWIFT_NAME(process(_:completion:));
  33. /**
  34. * Returns detected face results in the given image or `nil` if there was an error. The detection is
  35. * performed synchronously on the calling thread.
  36. *
  37. * @discussion It is advised to call this method off the main thread to avoid blocking the UI. As a
  38. * result, an `NSException` is raised if this method is called on the main thread.
  39. * @param image The vision image to use for detecting faces.
  40. * @param error An optional error parameter populated when there is an error during detection.
  41. * @return Array of faces detected in the given image or `nil` if there was an error.
  42. */
  43. - (nullable NSArray<FIRVisionFace *> *)resultsInImage:(FIRVisionImage *)image
  44. error:(NSError **)error;
  45. @end
  46. NS_ASSUME_NONNULL_END