// // KMGOCRManager.h // // // // // #import typedef NS_ENUM(NSUInteger, KMOCRType) { KMOCRType_Google, KMOCRType_Apple }; extern NSString * KMGOCRLanguageCodeKey; extern NSString * KMGOCRLanguageStringKey; @interface KMGOCRResult : NSObject @property (nonatomic,retain) NSString *text; @property (nonatomic,retain) NSString *locale; @property (nonatomic,assign) CGRect textBounds; @end @class KMGOCRManager; @protocol KMGOCRManagerDelegate @optional - (void)GOCRManagerDidStartOCR:(KMGOCRManager *)manager; - (void)GOCRManagerDidFinishOCR:(KMGOCRManager *)manager; - (void)GOCRManager:(KMGOCRManager *)manager didCancelOCRImageAtIndex:(NSInteger)index; - (void)GOCRManager:(KMGOCRManager *)manager didStartOCRImageAtIndex:(NSInteger)index; - (void)GOCRManager:(KMGOCRManager *)manager didFinishOCRImageAtIndex:(NSInteger)index results:(NSArray *)results; - (void)CHOCRManager:(KMGOCRManager *)manager didFinishOCRImageAtIndex:(NSInteger)index results:(NSArray *)results;//17方案 - (void)GOCRManager:(KMGOCRManager *)manager didFailureOCRImageAtIndex:(NSInteger)index error:(NSError *)error; @end @interface KMGOCRManager : NSObject @property (nonatomic,assign) id delegate; @property (nonatomic,readonly) NSMutableArray *images; @property (nonatomic,assign) KMOCRType OCRType; @property (nonatomic,retain) NSMutableArray *selectedLanguages; /* isGOCR : GOCR=NO/OCR=YES */ @property (nonatomic,assign) BOOL isOCR; + (KMGOCRManager *)defaultManager; + (NSArray *)languages; - (void)createPDFFile:(NSString *)filePath imagePaths:(NSArray *)paths results:(NSArray *)resultsArray scale:(CGFloat)scale; - (void)recognitionImages:(NSArray *)images withLanguages:(NSArray *)languages; //- (void)recognitionImages:(NSArray *)images withLanguages:(NSArray *)languages fileType:(NSString * _Nullable)fileType filePath:(NSURL *)filePath; /** Google OCR 设置参数进行转档. @param images 需要转档的NSImage 数组对象 @param languages 设置的识别s语言 @param fileType 设置转档的文件格式,可为空 @param filePath 设置保存文件的路径,可为空 */ - (void)recognitionImages:(NSArray *)images withLanguages:(NSArray *)languages fileType:(NSString * _Nullable)fileType filePath:(NSURL * _Nullable)filePath; - (void)cancelRecognition; @end @interface KMOCROperationQueue : NSOperationQueue + (instancetype)sharedInstance; - (void)addOCROperation:(NSOperation *)op; #pragma mark - cancel - (void)cancelAll; @end