FIRVisionTextRecognizer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #import <Foundation/Foundation.h>
  2. @class FIRVisionImage;
  3. @class FIRVisionText;
  4. NS_ASSUME_NONNULL_BEGIN
  5. /**
  6. * The callback to invoke when the text recognition completes.
  7. *
  8. * @param text Recognized text in the image or `nil` if there was an error.
  9. * @param error The error or `nil`.
  10. */
  11. typedef void (^FIRVisionTextRecognitionCallback)(FIRVisionText *_Nullable text,
  12. NSError *_Nullable error)
  13. NS_SWIFT_NAME(VisionTextRecognitionCallback);
  14. /**
  15. * @enum VisionTextRecognizerType
  16. * An enum of text recognizer types.
  17. */
  18. typedef NS_ENUM(NSInteger, FIRVisionTextRecognizerType) {
  19. /**
  20. * On-Device recognizer type.
  21. */
  22. FIRVisionTextRecognizerTypeOnDevice,
  23. /**
  24. * Cloud recognizer type.
  25. */
  26. FIRVisionTextRecognizerTypeCloud,
  27. } NS_SWIFT_NAME(VisionTextRecognizerType);
  28. /**
  29. * An on-device or cloud text recognizer that recognizes text in an image.
  30. */
  31. NS_SWIFT_NAME(VisionTextRecognizer)
  32. @interface FIRVisionTextRecognizer : NSObject
  33. /**
  34. * The text recognizer type.
  35. */
  36. @property(nonatomic, readonly) FIRVisionTextRecognizerType type;
  37. /**
  38. * Unavailable. Use `Vision` factory methods.
  39. */
  40. - (instancetype)init NS_UNAVAILABLE;
  41. /**
  42. * Processes the given image for on-device or cloud text recognition.
  43. *
  44. * @param image The image to process for recognizing text.
  45. * @param completion Handler to call back on the main queue when text recognition completes.
  46. */
  47. - (void)processImage:(FIRVisionImage *)image
  48. completion:(FIRVisionTextRecognitionCallback)completion
  49. NS_SWIFT_NAME(process(_:completion:));
  50. @end
  51. NS_ASSUME_NONNULL_END