123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //
- // KMGOCRManager.h
- //
- //
- //
- //
- //
- #import <Foundation/Foundation.h>
- 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 <NSObject>
- @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<KMGOCRResult *> *)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<KMGOCRManagerDelegate> 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
|