Sfoglia il codice sorgente

更新IPUOcr插件

huangyl3 5 anni fa
parent
commit
6f2465aff8

+ 6 - 0
IPUCommon/IPUOcr.framework/Headers/IPUOcrRequest.h

@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN
18 18
                   needMark:(BOOL)needMark
19 19
                   sdk_type:(int)sdk_type
20 20
                    sdk_key:(NSString *)sdk_key
21
              back_pic_type:(int)back_pic_type
22
                   max_size:(int)max_size
21 23
                    success:(IPUOcrRequestSuccessBlock)successBlock
22 24
                     failed:(IPUOcrRequestFailedBlock)failedBlock;
23 25
@ -26,6 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
26 28
                    needMark:(BOOL)needMark
27 29
                    sdk_type:(int)sdk_type
28 30
                     sdk_key:(NSString *)sdk_key
31
               back_pic_type:(int)back_pic_type
32
                    max_size:(int)max_size
29 33
                     success:(IPUOcrRequestSuccessBlock)successBlock
30 34
                      failed:(IPUOcrRequestFailedBlock)failedBlock;
31 35
@ -34,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
34 38
                      needMark:(BOOL)needMark
35 39
                         token:(NSString*)token
36 40
                      acc_type:(int)acc_type
41
                 back_pic_type:(int)back_pic_type
42
                      max_size:(int)max_size
37 43
                       success:(IPUOcrRequestSuccessBlock)successBlock
38 44
                        failed:(IPUOcrRequestFailedBlock)failedBlock;
39 45

+ 4 - 0
IPUCommon/IPUOcr.framework/Headers/IPUOcrRequestFoundation.h

@ -38,6 +38,8 @@ typedef void(^IPUOcrRequestFailedBlock)(NSString *error);
38 38
39 39
+ (NSString *)imageToBase64_JPG:(UIImage *)image;
40 40
41
+ (NSString *)imageToBase64_JPG:(UIImage *)image quality:(float)quality;
42
41 43
+ (UIImage *)rectImage:(UIImage *)image rects:(NSArray *)rects color:(UIColor *)color;
42 44
// 带序号的
43 45
+ (UIImage *)rectImage2:(UIImage *)image rects:(NSArray *)rects color:(UIColor *)color;
@ -50,6 +52,8 @@ typedef void(^IPUOcrRequestFailedBlock)(NSString *error);
50 52
51 53
+ (NSData *)toJSONData:(id)data;
52 54
55
+ (UIImage *)fixOrientation:(UIImage *)image;
56
53 57
@end
54 58
55 59
NS_ASSUME_NONNULL_END

BIN
IPUCommon/IPUOcr.framework/IPUOcr


BIN
IPUCommon/IPUOcr.framework/Info.plist


BIN
display-center/display-center.xcworkspace/xcuserdata/huangyulin.xcuserdatad/UserInterfaceState.xcuserstate


+ 32 - 11
display-center/display-center/IPUOCRPlugin.m

@ -12,7 +12,6 @@
12 12
13 13
@implementation IPUOCRPlugin
14 14
15
16 15
/*
17 16
 身份证识别,水牌识别,通用
18 17
 默认callBack():返回json数组
@ -21,8 +20,8 @@
21 20
 params[2]-needMark: 是否返回包含位置信息的图片,BOOL类型,YES:返回图片base64字符串,NO:不返回
22 21
 params[3]-sdk_type:识别的第三方库标识:int类型,0:百度-OCR库,1:AI2-OCR库。
23 22
 params[4]-sdk_key:     鉴权参数,string类型(json串),
24
                     如果sdk_type=0,sdk={"token":"xxx","appid":"xxx"},
25
                     如果sdk_type=1,sdk={"token":"xxx","sk":"xxx","ak":"xxx"}
23
 如果sdk_type=0,sdk={"token":"xxx","appid":"xxx"},
24
 如果sdk_type=1,sdk={"token":"xxx","sk":"xxx","ak":"xxx"}
26 25
 err:错误信息返回。
27 26
 */
28 27
@ -40,8 +39,10 @@
40 39
        if ([sdk_key containsString:@"'"]) {
41 40
            sdk_key = [sdk_key stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
42 41
        }
42
        int back_pic_type = 0; //0:表示base64,1:表示返回图片地址
43
        int max_size = 50; //图片的最大值:(kb)默认为50Kb
43 44
        
44
        [IPUOcrRequest ipuOcrGetIdCardInfo:type picInfo:picInfo needMark:needMark sdk_type:sdk_type sdk_key:sdk_key success:^(id  _Nonnull result) {
45
        [IPUOcrRequest ipuOcrGetIdCardInfo:type picInfo:picInfo needMark:needMark sdk_type:sdk_type sdk_key:sdk_key back_pic_type:back_pic_type max_size:max_size success:^(id  _Nonnull result) {
45 46
            NSDictionary *resultDic = result;
46 47
            NSMutableArray *callBackArray = [NSMutableArray arrayWithCapacity:0];
47 48
            [callBackArray addObject:resultDic[@"result"]];
@ -69,8 +70,10 @@
69 70
        if ([sdk_key containsString:@"'"]) {
70 71
            sdk_key = [sdk_key stringByReplacingOccurrencesOfString:@"'" withString:@"\""];
71 72
        }
73
        int back_pic_type = 0; //0:表示base64,1:表示返回图片地址
74
        int max_size = 50; //图片的最大值:(kb)默认为50Kb
72 75
        
73
        [IPUOcrRequest ipuOcrGetFloCardInfo:type picInfo:picInfo needMark:needMark sdk_type:sdk_type sdk_key:sdk_key success:^(id  _Nonnull result) {
76
        [IPUOcrRequest ipuOcrGetFloCardInfo:type picInfo:picInfo needMark:needMark sdk_type:sdk_type sdk_key:sdk_key back_pic_type:back_pic_type max_size:max_size success:^(id  _Nonnull result) {
74 77
            NSDictionary *resultDic = result;
75 78
            NSMutableArray *callBackArray = [NSMutableArray arrayWithCapacity:0];
76 79
            [callBackArray addObject:resultDic[@"result"]];
@ -92,7 +95,9 @@
92 95
 params[2]-needMark: 是否返回包含位置信息的图片,BOOL类型,YES:返回图片base64字符串,NO:不返回
93 96
 params[3]-token:   百度接口的Token
94 97
 params[4]-acc_type:接口类型,int,0:高精度,1:一般精度
95
 err:错误信息返回。
98
 params[5]-back_pic_type:接口类型,int,0:base64,1:图片路径
99
 params[6]-max_size:picInfo的最大size(单位为kb);默认最小50kb,前提是type=1,为图片地址;
100
 err:错误信息返回。d
96 101
 */
97 102
- (void)getFloCardInfoBD:(NSArray *)params {
98 103
    if (!params || params.count < 4) {
@ -103,23 +108,39 @@
103 108
        NSString *picInfo = params[1];
104 109
        BOOL needMark = [params[2] boolValue];
105 110
        NSString *token = params[3];
111
        
112
        // 精度
106 113
        int acc_type = 0;
107 114
        if (params.count == 5) {
108 115
            acc_type = [params[4] intValue];
109 116
        }
110
        [IPUOcrRequest ipuOcrGetFloCardInfoBD:type picInfo:picInfo needMark:needMark token:token acc_type:acc_type success:^(id  _Nonnull result) {
117
        
118
        // 返回的图片类型
119
        int back_pic_type = 0; //0:表示base64,1:表示返回图片地址
120
        if (params.count == 6) {
121
            back_pic_type = [params[5] intValue];
122
        }
123
        
124
        // 图片的最大值:(kb)默认为50Kb
125
        int max_size = 200;
126
        if (params.count == 7) {
127
            max_size = [params[6] intValue];
128
        }
129
        
130
        
131
        __weak typeof(self) weakSelf = self;
132
        [IPUOcrRequest ipuOcrGetFloCardInfoBD:type picInfo:picInfo needMark:needMark token:token acc_type:acc_type back_pic_type:back_pic_type max_size:max_size success:^(id  _Nonnull result) {
111 133
            NSDictionary *resultDic = result;
112 134
            NSMutableArray *callBackArray = [NSMutableArray arrayWithCapacity:0];
113 135
            [callBackArray addObject:resultDic[@"result"]];
114 136
            if (needMark) {
115 137
                [callBackArray addObject:resultDic[@"loc"]];
116 138
            }
117
            [self callback:[IPUJSONHelper toJSONString:[callBackArray mutableCopy]]];
139
            NSString *jsonString = [IPUJSONHelper toJSONString:[callBackArray mutableCopy]];
140
            [weakSelf callback:jsonString];
118 141
        } failed:^(NSString * _Nonnull error) {
119
            [self error:error];
142
            [weakSelf error:error];
120 143
        }];
121
        
122 144
    }
123 145
}
124
125 146
@end