接口说明
通用文字识别
用户向服务请求识别某张图中的所有文字。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("language_type", "CHN_ENG");
5 options.put("detect_direction", "true");
6 options.put("detect_language", "true");
7 options.put("probability", "true");
8
9
10 // 参数为本地图片路径
11 String image = "test.jpg";
12 JSONObject res = client.basicGeneral(image, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.basicGeneral(file, options);
18 System.out.println(res.toString(2));
19
20
21 // 通用文字识别, 图片参数为远程url图片
22 JSONObject res = client.basicGeneralUrl(url, options);
23 System.out.println(res.toString(2));
24
25 }
通用文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
url | 是 | String | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
language_type | 否 | String | CHN_ENG ENG POR FRE GER ITA SPA RUS JAP KOR |
CHN_ENG | 识别语言类型,默认为CHN_ENG。可选值包括: - CHN_ENG:中英文混合; - ENG:英文; - POR:葡萄牙语; - FRE:法语; - GER:德语; - ITA:意大利语; - SPA:西班牙语; - RUS:俄语; - JAP:日语; - KOR:韩语; |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | String | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 |
通用文字识别 返回数据参数详情
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array | 定位和识别结果数组 |
+words | 否 | string | 识别结果字符串 |
probability | 否 | object | 行置信度信息;如果输入参数 probability = true 则输出 |
+average | 否 | number | 行置信度平均值 |
+variance | 否 | number | 行置信度方差 |
+min | 否 | number | 行置信度最小值 |
通用文字识别 返回示例
1{
2"log_id": 2471272194,
3"words_result_num": 2,
4"words_result":
5 [
6 {"words": " TSINGTAO"},
7 {"words": "青島睥酒"}
8 ]
9}
通用文字识别(高精度版)
用户向服务请求识别某张图中的所有文字,相对于通用文字识别该产品精度更高,但是识别耗时会稍长。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("detect_direction", "true");
5 options.put("probability", "true");
6
7
8 // 参数为本地图片路径
9 String image = "test.jpg";
10 JSONObject res = client.basicAccurateGeneral(image, options);
11 System.out.println(res.toString(2));
12
13 // 参数为本地图片二进制数组
14 byte[] file = readImageFile(image);
15 res = client.basicAccurateGeneral(file, options);
16 System.out.println(res.toString(2));
17
18 }
通用文字识别(高精度版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 |
通用文字识别(高精度版) 返回数据参数详情
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array | 定位和识别结果数组 |
+words | 否 | string | 识别结果字符串 |
probability | 否 | object | 行置信度信息;如果输入参数 probability = true 则输出 |
+average | 否 | number | 行置信度平均值 |
+variance | 否 | number | 行置信度方差 |
+min | 否 | number | 行置信度最小值 |
通用文字识别(高精度版) 返回示例
参考通用文字识别返回示例
通用文字识别(含位置信息版)
用户向服务请求识别某张图中的所有文字,并返回文字在图中的位置信息。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("recognize_granularity", "big");
5 options.put("language_type", "CHN_ENG");
6 options.put("detect_direction", "true");
7 options.put("detect_language", "true");
8 options.put("vertexes_location", "true");
9 options.put("probability", "true");
10
11
12 // 参数为本地图片路径
13 String image = "test.jpg";
14 JSONObject res = client.general(image, options);
15 System.out.println(res.toString(2));
16
17 // 参数为本地图片二进制数组
18 byte[] file = readImageFile(image);
19 res = client.general(file, options);
20 System.out.println(res.toString(2));
21
22
23 // 通用文字识别(含位置信息版), 图片参数为远程url图片
24 JSONObject res = client.generalUrl(url, options);
25 System.out.println(res.toString(2));
26
27 }
通用文字识别(含位置信息版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
url | 是 | String | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
recognize_granularity | 否 | String | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
language_type | 否 | String | CHN_ENG ENG POR FRE GER ITA SPA RUS JAP KOR |
CHN_ENG | 识别语言类型,默认为CHN_ENG。可选值包括: - CHN_ENG:中英文混合; - ENG:英文; - POR:葡萄牙语; - FRE:法语; - GER:德语; - ITA:意大利语; - SPA:西班牙语; - RUS:俄语; - JAP:日语; - KOR:韩语; |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | String | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
vertexes_location | 否 | String | true false |
false | 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 | |
paragraph | 否 | String | true false |
是否输出段落信息 | |
通用文字识别(含位置信息版) 返回数据参数详情 |
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result | 是 | array | 定位和识别结果数组 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
+vertexes_location | 否 | array | 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在 |
++x | 是 | number | 水平坐标(坐标0点为左上角) |
++y | 是 | number | 垂直坐标(坐标0点为左上角) |
+location | 是 | array | 位置数组(坐标0点为左上角) |
++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | 是 | number | 表示定位位置的长方形的宽度 |
++height | 是 | number | 表示定位位置的长方形的高度 |
+words | 否 | number | 识别结果字符串 |
+chars | 否 | array | 单字符结果,recognize_granularity=small时存在 |
++location | 是 | array | 位置数组(坐标0点为左上角) |
+++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
+++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
+++width | 是 | number | 表示定位定位位置的长方形的宽度 |
+++height | 是 | number | 表示位置的长方形的高度 |
++char | 是 | string | 单字符识别结果 |
probability | 否 | object | 行置信度信息;如果输入参数 probability = true 则输出 |
+ average | 否 | number | 行置信度平均值 |
+ variance | 否 | number | 行置信度方差 |
+ min | 否 | number | 行置信度最小值 |
通用文字识别(含位置信息版) 返回示例
1{
2"log_id": 3523983603,
3"direction": 0, //detect_direction=true时存在
4"words_result_num": 2,
5"words_result": [
6 {
7 "location": {
8 "left": 35,
9 "top": 53,
10 "width": 193,
11 "height": 109
12 },
13 "words": "感动",
14 "chars": [ //recognize_granularity=small时存在
15 {
16 "location": {
17 "left": 56,
18 "top": 65,
19 "width": 69,
20 "height": 88
21 },
22 "char": "感"
23 },
24 {
25 "location": {
26 "left": 140,
27 "top": 65,
28 "width": 70,
29 "height": 88
30 },
31 "char": "动"
32 }
33 ]
34 }
35 ...
36]
37}
通用文字识别(含位置高精度版)
用户向服务请求识别某张图中的所有文字,并返回文字在图片中的坐标信息,相对于通用文字识别(含位置信息版)该产品精度更高,但是识别耗时会稍长。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("recognize_granularity", "big");
5 options.put("detect_direction", "true");
6 options.put("vertexes_location", "true");
7 options.put("probability", "true");
8
9
10 // 参数为本地图片路径
11 String image = "test.jpg";
12 JSONObject res = client.accurateGeneral(image, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.accurateGeneral(file, options);
18 System.out.println(res.toString(2));
19
20 }
通用文字识别(含位置高精度版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
recognize_granularity | 否 | String | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
vertexes_location | 否 | String | true false |
false | 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 |
通用文字识别(含位置高精度版) 返回数据参数详情
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result | 是 | array | 定位和识别结果数组 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
+vertexes_location | 否 | array | 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在 |
++x | 是 | number | 水平坐标(坐标0点为左上角) |
++y | 是 | number | 垂直坐标(坐标0点为左上角) |
+location | 是 | array | 位置数组(坐标0点为左上角) |
++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | 是 | number | 表示定位位置的长方形的宽度 |
++height | 是 | number | 表示定位位置的长方形的高度 |
+words | 否 | number | 识别结果字符串 |
+chars | 否 | array | 单字符结果,recognize_granularity=small时存在 |
++location | 是 | array | 位置数组(坐标0点为左上角) |
+++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
+++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
+++width | 是 | number | 表示定位定位位置的长方形的宽度 |
+++height | 是 | number | 表示位置的长方形的高度 |
++char | 是 | string | 单字符识别结果 |
probability | 否 | object | 行置信度信息;如果输入参数 probability = true 则输出 |
+ average | 否 | number | 行置信度平均值 |
+ variance | 否 | number | 行置信度方差 |
+ min | 否 | number | 行置信度最小值 |
通用文字识别(含位置高精度版) 返回示例
1{
2"log_id": 3523983603,
3"direction": 0, //detect_direction=true时存在
4"words_result_num": 2,
5"words_result": [
6 {
7 "location": {
8 "left": 35,
9 "top": 53,
10 "width": 193,
11 "height": 109
12 },
13 "words": "感动",
14 "chars": [ //recognize_granularity=small时存在
15 {
16 "location": {
17 "left": 56,
18 "top": 65,
19 "width": 69,
20 "height": 88
21 },
22 "char": "感"
23 },
24 {
25 "location": {
26 "left": 140,
27 "top": 65,
28 "width": 70,
29 "height": 88
30 },
31 "char": "动"
32 }
33 ]
34 }
35 ...
36]
37}
通用文字识别(含生僻字版)
【该服务已停止更新,如需更好的识别效果请使用通用文字识别(高精度版 / 高精度含位置版),此两项服务已扩充字库,可支持生僻字识别】字库范围更大,支持对图片中的生僻字进行识别
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("language_type", "CHN_ENG");
5 options.put("detect_direction", "true");
6 options.put("detect_language", "true");
7 options.put("probability", "true");
8
9
10 // 参数为本地图片路径
11 String image = "test.jpg";
12 JSONObject res = client.enhancedGeneral(image, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.enhancedGeneral(file, options);
18 System.out.println(res.toString(2));
19
20
21 // 通用文字识别(含生僻字版), 图片参数为远程url图片
22 JSONObject res = client.enhancedGeneralUrl(url, options);
23 System.out.println(res.toString(2));
24
25 }
通用文字识别(含生僻字版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
url | 是 | String | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
language_type | 否 | String | CHN_ENG ENG POR FRE GER ITA SPA RUS JAP KOR |
CHN_ENG | 识别语言类型,默认为CHN_ENG。可选值包括: - CHN_ENG:中英文混合; - ENG:英文; - POR:葡萄牙语; - FRE:法语; - GER:德语; - ITA:意大利语; - SPA:西班牙语; - RUS:俄语; - JAP:日语; - KOR:韩语; |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | String | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 |
通用文字识别(含生僻字版) 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | int32 | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result | 是 | array() | 识别结果数组 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
+words | 否 | string | 识别结果字符串 |
probability | 否 | object | 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值 |
+ average | 否 | number | 行置信度平均值 |
+ variance | 否 | number | 行置信度方差 |
+ min | 否 | number | 行置信度最小值 |
通用文字识别(含生僻字版) 返回示例
1{
2"log_id": 2471272194,
3"words_result_num": 2,
4"words_result":
5 [
6 {"words": " TSINGTAO"},
7 {"words": "青島睥酒"}
8 ]
9}
网络图片文字识别
用户向服务请求识别一些网络上背景复杂,特殊字体的文字。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("detect_direction", "true");
5 options.put("detect_language", "true");
6
7
8 // 参数为本地图片路径
9 String image = "test.jpg";
10 JSONObject res = client.webImage(image, options);
11 System.out.println(res.toString(2));
12
13 // 参数为本地图片二进制数组
14 byte[] file = readImageFile(image);
15 res = client.webImage(file, options);
16 System.out.println(res.toString(2));
17
18
19 // 网络图片文字识别, 图片参数为远程url图片
20 JSONObject res = client.webImageUrl(url, options);
21 System.out.println(res.toString(2));
22
23 }
网络图片文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
url | 是 | String | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | String | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
网络图片文字识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result | 是 | array() | 识别结果数组 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
+words | 否 | string | 识别结果字符串 |
probability | 否 | object | 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值 |
+ average | 否 | number | 行置信度平均值 |
+ variance | 否 | number | 行置信度方差 |
+ min | 否 | number | 行置信度最小值 |
网络图片文字识别 返回示例
1{
2"log_id": 2471272194,
3"words_result_num": 2,
4"words_result":
5 [
6 {"words": " TSINGTAO"},
7 {"words": "青島睥酒"}
8 ]
9}
身份证识别
用户向服务请求识别身份证,身份证识别包括正面和背面。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("detect_direction", "true");
5 options.put("detect_risk", "false");
6
7 String idCardSide = "back";
8
9 // 参数为本地图片路径
10 String image = "test.jpg";
11 JSONObject res = client.idcard(image, idCardSide, options);
12 System.out.println(res.toString(2));
13
14 // 参数为本地图片二进制数组
15 byte[] file = readImageFile(image);
16 res = client.idcard(file, idCardSide, options);
17 System.out.println(res.toString(2));
18
19 }
身份证识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
id_card_side | 是 | String | front - 身份证含照片的一面 back - 身份证带国徽的一面 |
front:身份证含照片的一面;back:身份证带国徽的一面 | |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_risk | 否 | String | true - 开启 false - 不开启 |
false | 是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。可选值:true-开启;false-不开启 |
detect_photo | 否 | String | true - 开启 false - 不开启 |
false | 是否检测头像内容,默认不检测。可选值:true-检测头像并返回头像的 base64 编码及位置信息 |
detect_card | 否 | String | true - 开启 false - 不开启 |
false | 是否检测身份证进行裁剪,默认不检测。可选值:true-检测身份证并返回证照的 base64 编码及位置信息 |
身份证识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
image_status | 是 | string | normal-识别正常 reversed_side-未摆正身份证 non_idcard-上传的图片中不包含身份证 blurred-身份证模糊 over_exposure-身份证关键字段反光或过曝 unknown-未知状态 |
risk_type | 否 | string | 输入参数 detect_risk = true 时,则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknow-其他未知情况 |
edit_tool | 否 | string | 如果参数 detect_risk = true 时,则返回此字段。如果检测身份证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值无此参数 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result | 是 | array(object) | 定位和识别结果数组 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
+location | 是 | array(object) | 位置数组(坐标0点为左上角) |
++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | 是 | number | 表示定位位置的长方形的宽度 |
++height | 是 | number | 表示定位位置的长方形的高度 |
+words | 否 | string | 识别结果字符串 |
身份证识别 返回示例
1{
2 "log_id": 2648325511,
3 "direction": 0,
4 "image_status": "normal",
5 "idcard_type": "normal",
6 "edit_tool": "Adobe Photoshop CS3 Windows",
7 "words_result": {
8 "住址": {
9 "location": {
10 "left": 267,
11 "top": 453,
12 "width": 459,
13 "height": 99
14 },
15 "words": "南京市江宁区弘景大道3889号"
16 },
17 "公民身份号码": {
18 "location": {
19 "left": 443,
20 "top": 681,
21 "width": 589,
22 "height": 45
23 },
24 "words": "330881199904173914"
25 },
26 "出生": {
27 "location": {
28 "left": 270,
29 "top": 355,
30 "width": 357,
31 "height": 45
32 },
33 "words": "19990417"
34 },
35 "姓名": {
36 "location": {
37 "left": 267,
38 "top": 176,
39 "width": 152,
40 "height": 50
41 },
42 "words": "伍云龙"
43 },
44 "性别": {
45 "location": {
46 "left": 269,
47 "top": 262,
48 "width": 33,
49 "height": 52
50 },
51 "words": "男"
52 },
53 "民族": {
54 "location": {
55 "left": 492,
56 "top": 279,
57 "width": 30,
58 "height": 37
59 },
60 "words": "汉"
61 }
62 },
63 "words_result_num": 6
64}
银行卡识别
识别银行卡并返回卡号和发卡行。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5
6 // 参数为本地图片路径
7 String image = "test.jpg";
8 JSONObject res = client.bankcard(image, options);
9 System.out.println(res.toString(2));
10
11 // 参数为本地图片二进制数组
12 byte[] file = readImageFile(image);
13 res = client.bankcard(file, options);
14 System.out.println(res.toString(2));
15
16 }
银行卡识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 |
银行卡识别 返回数据参数详情
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
log_id | number | 是 | 请求标识码,随机数,唯一。 |
result | object | 是 | 返回结果 |
+bank_card_number | string | 是 | 银行卡卡号 |
+bank_name | string | 是 | 银行名,不能识别时为空 |
+bank_card_type | number | 是 | 银行卡类型,0:不能识别; 1: 借记卡; 2: 信用卡 |
银行卡识别 返回示例
1{
2 "log_id": 1447188951,
3 "result": {
4 "bank_card_number": "622500000000000",
5 "bank_name": "招商银行",
6 "bank_card_type": 1
7 }
8}
驾驶证识别
对机动车驾驶证所有关键字段进行识别。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("detect_direction", "true");
5
6
7 // 参数为本地图片路径
8 String image = "test.jpg";
9 JSONObject res = client.drivingLicense(image, options);
10 System.out.println(res.toString(2));
11
12 // 参数为本地图片二进制数组
13 byte[] file = readImageFile(image);
14 res = client.drivingLicense(file, options);
15 System.out.println(res.toString(2));
16
17 }
驾驶证识别 请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和image二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
detect_direction | 否 | string | true/false | - false:默认值,不检测朝向,朝向是指输入图像是正常方向、逆时针旋转90/180/270度 - true:检测朝向 |
driving_license_side | 否 | string | front/back | - front:默认值,识别驾驶证正页 - back:识别驾驶证副页 |
unified_valid_period | 否 | bool | true/false | - false: 默认值,不进行归一化处理 - true: 归一化格式输出驾驶证的「有效起始日期」+「有效期限」及「有效期限」+「至」两种输出格式归一化为「有效起始日期」+「失效日期」 |
quality_warn | 否 | string | true/false | 是否开启质量检测功能,仅在驾驶证正页识别时生效,- false:默认值,不输出质量告警信息- true: 输出驾驶证遮挡、不完整质量告警信息 |
risk_warn | 否 | string | true/false | 是否开启风险检测功能,- false:默认值,不输出风险告警信息 - true:开启,输出驾驶证复印、翻拍、PS等告警信息 |
驾驶证识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
direction | 否 | int32 | 图像方向,当 detect_direction=true 时返回该字段。 - - 1:未定义, - 0:正向, - 1:逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object | 识别结果 |
+ words | 否 | string | 识别结果字符串 |
warn_infos | 否 | array[] | 当输入参数 driving_license_side=front,且 quality_warn=true 时输出,- shield:驾驶证证照存在遮挡告警提示 - incomplete:驾驶证证照边框不完整告警提示 |
risk_type | 否 | string | 当输入参数 risk_warn=true 时返回识出的驾驶证的类型:normal-正常驾驶证;copy-复印件;screen-翻拍 |
edit_tool | 否 | string | 当输入参数 risk_warn=true 时返回,如果检测驾驶证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值为空 |
驾驶证识别 返回示例
1{
2 "errno": 0,
3 "msg": "success",
4 "data": {
5 "words_result_num": 10,
6 "words_result": {
7 "证号": {
8 "words": "3208231999053090"
9 },
10 "有效期限": {
11 "words": "6年"
12 },
13 "准驾车型": {
14 "words": "B2"
15 },
16 "有效起始日期": {
17 "words": "20101125"
18 },
19 "住址": {
20 "words": "江苏省南通市海门镇秀山新城"
21 },
22 "姓名": {
23 "words": "小欧欧"
24 },
25 "国籍": {
26 "words": "中国"
27 },
28 "出生日期": {
29 "words": "19990530"
30 },
31 "性别": {
32 "words": "男"
33 },
34 "初次领证日期": {
35 "words": "20100125"
36 }
37 }
38 }
39}
行驶证识别
对机动车行驶证所有关键字段进行识别。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("detect_direction", "true");
5 options.put("accuracy", "normal");
6
7
8 // 参数为本地图片路径
9 String image = "test.jpg";
10 JSONObject res = client.vehicleLicense(image, options);
11 System.out.println(res.toString(2));
12
13 // 参数为本地图片二进制数组
14 byte[] file = readImageFile(image);
15 res = client.vehicleLicense(file, options);
16 System.out.println(res.toString(2));
17
18 }
行驶证识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
vehicle_license_side | 否 | string | front/back | front | - front:识别行驶证主页- back:识别行驶证副页 |
unified | 否 | string | true/false | false | - false:不进行归一化处理- true:对输出字段进行归一化处理,将新/老版行驶证的“注册登记日期/注册日期”统一为”注册日期“进行输出 |
行驶证识别 返回数据参数详情
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array(object) | 识别结果数组 |
+words | 否 | string | 识别结果字符串 |
行驶证识别 返回示例
1{
2 "errno": 0,
3 "msg": "success",
4 "data": {
5 "words_result_num": 10,
6 "words_result": {
7 "品牌型号": {
8 "words": "保时捷GT37182RUCRE"
9 },
10 "发证日期": {
11 "words": "20160104"
12 },
13 "使用性质": {
14 "words": "非营运"
15 },
16 "发动机号码": {
17 "words": "20832"
18 },
19 "号牌号码": {
20 "words": "苏A001"
21 },
22 "所有人": {
23 "words": "圆圆"
24 },
25 "住址": {
26 "words": "南京市江宁区弘景大道"
27 },
28 "注册日期": {
29 "words": "20160104"
30 },
31 "车辆识别代号": {
32 "words": "HCE58"
33 },
34 "车辆类型": {
35 "words": "小型轿车"
36 }
37 }
38 }
39}
车牌识别
识别机动车车牌,并返回号牌号码和车牌颜色。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("multi_detect", "true");
5
6
7 // 参数为本地图片路径
8 String image = "test.jpg";
9 JSONObject res = client.plateLicense(image, options);
10 System.out.println(res.toString(2));
11
12 // 参数为本地图片二进制数组
13 byte[] file = readImageFile(image);
14 res = client.plateLicense(file, options);
15 System.out.println(res.toString(2));
16
17 }
车牌识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
multi_detect | 否 | String | true false |
false | 是否检测多张车牌,默认为false,当置为true的时候可以对一张图片内的多张车牌进行识别 |
车牌识别 返回数据参数详情
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
log_id | uint64 | 是 | 请求标识码,随机数,唯一 |
Color | string | 是 | 车牌颜色 |
number | string | 是 | 车牌号码 |
车牌识别 返回示例
1{
2 "log_id": 3583925545,
3 "words_result": {
4 "color": "blue",
5 "number": "苏HS7766"
6 }
7}
营业执照识别
识别营业执照,并返回关键字段的值,包括单位名称、法人、地址、有效期、证件编号、社会信用代码等。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5
6 // 参数为本地图片路径
7 String image = "test.jpg";
8 JSONObject res = client.businessLicense(image, options);
9 System.out.println(res.toString(2));
10
11 // 参数为本地图片二进制数组
12 byte[] file = readImageFile(image);
13 res = client.businessLicense(file, options);
14 System.out.println(res.toString(2));
15
16 }
营业执照识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 |
营业执照识别 返回数据参数详情
参数 | 是否必须 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | number | 请求标识码,随机数,唯一。 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array(object) | 识别结果数组 |
left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | number | 表示定位位置的长方形的宽度 |
height | 是 | number | 表示定位位置的长方形的高度 |
words | 否 | string | 识别结果字符串 |
营业执照识别 返回示例
1{
2 "log_id": 490058765,
3 "words_result": {
4 "单位名称": {
5 "location": {
6 "left": 500,
7 "top": 479,
8 "width": 618,
9 "height": 54
10 },
11 "words": "袁氏财团有限公司"
12 },
13 "法人": {
14 "location": {
15 "left": 938,
16 "top": 557,
17 "width": 94,
18 "height": 46
19 },
20 "words": "袁运筹"
21 },
22 "地址": {
23 "location": {
24 "left": 503,
25 "top": 644,
26 "width": 574,
27 "height": 57
28 },
29 "words": "江苏省南京市中山东路19号"
30 },
31 "有效期": {
32 "location": {
33 "left": 779,
34 "top": 1108,
35 "width": 271,
36 "height": 49
37 },
38 "words": "2015年02月12日"
39 },
40 "证件编号": {
41 "location": {
42 "left": 1219,
43 "top": 357,
44 "width": 466,
45 "height": 39
46 },
47 "words": "苏餐证字(2019)第666602666661号"
48 },
49 "社会信用代码": {
50 "location": {
51 "left": 0,
52 "top": 0,
53 "width": 0,
54 "height": 0
55 },
56 "words": "无"
57 }
58 },
59 "words_result_num": 6
60}
通用票据识别
用户向服务请求识别医疗票据、增值税发票、出租车票、保险保单等票据类图片中的所有文字,并返回文字在图中的位置信息。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("recognize_granularity", "big");
5 options.put("probability", "true");
6 options.put("accuracy", "normal");
7 options.put("detect_direction", "true");
8
9
10 // 参数为本地图片路径
11 String image = "test.jpg";
12 JSONObject res = client.receipt(image, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.receipt(file, options);
18 System.out.println(res.toString(2));
19
20 }
通用票据识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 | ||
recognize_granularity | 否 | String | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
probability | 否 | String | true false |
是否返回识别结果中每一行的置信度 | |
accuracy | 否 | String | normal - 使用快速服务 |
normal 使用快速服务,1200ms左右时延;缺省或其它值使用高精度服务,1600ms左右时延 | |
detect_direction | 否 | String | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
通用票据识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array() | 定位和识别结果数组 |
location | 是 | object | 位置数组(坐标0点为左上角) |
left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | number | 表示定位位置的长方形的宽度 |
height | 是 | number | 表示定位位置的长方形的高度 |
words | 是 | string | 识别结果字符串 |
chars | 否 | array() | 单字符结果,recognize_granularity=small时存在 |
location | 是 | array() | 位置数组(坐标0点为左上角) |
left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | number | 表示定位定位位置的长方形的宽度 |
height | 是 | number | 表示位置的长方形的高度 |
char | 是 | string | 单字符识别结果 |
probability | 否 | object | 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值 |
通用票据识别 返回示例
1{
2 "log_id": 2661573626,
3 "words_result": [
4 {
5 "location": {
6 "left": 10,
7 "top": 3,
8 "width": 121,
9 "height": 24
10 },
11 "words": "姓名:小明明",
12 "chars": [
13 {
14 "location": {
15 "left": 16,
16 "top": 6,
17 "width": 17,
18 "height": 20
19 },
20 "char": "姓"
21 }
22 ...
23 ]
24 },
25 {
26 "location": {
27 "left": 212,
28 "top": 3,
29 "width": 738,
30 "height": 24
31 },
32 "words": "卡号/病案号:105353990标本编号:150139071送检科室:血液透析门诊病房",
33 "chars": [
34 {
35 "location": {
36 "left": 218,
37 "top": 6,
38 "width": 18,
39 "height": 21
40 },
41 "char": "卡"
42 }
43 ...
44 ]
45 }
46 ],
47 "words_result_num": 2
48}
自定义模板文字识别
自定义模板文字识别,是针对百度官方没有推出相应的模板,但是当用户需要对某一类卡证/票据(如房产证、军官证、火车票等)进行结构化的提取内容时,可以使用该产品快速制作模板,进行识别。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 options.put("templateSign", "Nsdax2424asaAS791823112");
6
7 // 参数为本地图片路径
8 String image = "test.jpg";
9 JSONObject res = client.custom(image, options);
10 System.out.println(res.toString(2));
11
12 // 参数为本地图片二进制数组
13 byte[] file = readImageFile(image);
14 res = client.custom(file, options);
15 System.out.println(res.toString(2));
16 }
自定义模板文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 |
templateSign | 否 | String | 您在自定义文字识别平台制作的模板的ID |
classifierId | 否 | string | 分类器Id。这个参数和templateSign至少存在一个,优先使用templateSign。存在templateSign时,表示使用指定模板;如果没有templateSign而有classifierId,表示使用分类器去判断使用哪个模板 |
自定义模板文字识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
error_code | number | number | 0代表成功,如果有错误码返回可以参考下方错误码列表排查问题 |
error_msg | 是 | string | 具体的失败信息,可以参考下方错误码列表排查问题 |
data | jsonObject | 识别返回的结果 |
自定义模板文字识别 返回示例
1{
2 "isStructured": true,
3 "ret": [
4 {
5 "charset": [
6 {
7 "rect": {
8 "top": 183,
9 "left": 72,
10 "width": 14,
11 "height": 28
12 },
13 "word": "5"
14 },
15 {
16 "rect": {
17 "top": 183,
18 "left": 90,
19 "width": 14,
20 "height": 28
21 },
22 "word": "4"
23 },
24 {
25 "rect": {
26 "top": 183,
27 "left": 103,
28 "width": 15,
29 "height": 28
30 },
31 "word": "."
32 },
33 {
34 "rect": {
35 "top": 183,
36 "left": 116,
37 "width": 14,
38 "height": 28
39 },
40 "word": "5"
41 },
42 {
43 "rect": {
44 "top": 183,
45 "left": 133,
46 "width": 19,
47 "height": 28
48 },
49 "word": "元"
50 }
51 ],
52 "word_name": "票价",
53 "word": "54.5元"
54 },
55 {
56 "charset": [
57 {
58 "rect": {
59 "top": 144,
60 "left": 35,
61 "width": 14,
62 "height": 28
63 },
64 "word": "2"
65 },
66 {
67 "rect": {
68 "top": 144,
69 "left": 53,
70 "width": 14,
71 "height": 28
72 },
73 "word": "0"
74 },
75 {
76 "rect": {
77 "top": 144,
78 "left": 79,
79 "width": 14,
80 "height": 28
81 },
82 "word": "1"
83 },
84 {
85 "rect": {
86 "top": 144,
87 "left": 97,
88 "width": 14,
89 "height": 28
90 },
91 "word": "7"
92 }
93 ]
94 ]
95}
试卷分析与识别
可对文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景。
1public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.docAnalysis(image, options);
8 System.out.println(res.toString(2));
9
10 // 参数为本地图片二进制数组
11 byte[] file = readImageFile(image);
12 res = client.docAnalysis(file, options);
13 System.out.println(res.toString(2));
14}
识别结果请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | true | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少64px,最长边最大4096px。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) | |
language_type | false | string | CHN_ENG/ ENG | 识别语言类型,默认为CHN_ENG 可选值包括:=CHN_ENG:中英文 =ENG:英文 | |
result_type | false | string | big/small | 返回识别结果是按单行结果返回,还是按单字结果返回,默认为big。 =big:返回行识别结果 =small:返回行识别结果之上还会返回单字结果 | |
detect_direction | false | string | true/false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。其中, 0 :正向 1:逆时针旋转90度 2:逆时针旋转180度 3:逆时针旋转270度 | |
line_probability | false | string | true/false | 是否返回每行识别结果的置信度。默认为false | |
words_type | false | string | handwring_only/ handprint_mix | 文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别 | |
layout_analysis | false | string | true/false | 是否分析文档版面:包括图、表、标题、段落的分析输出 |
识别结果 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | true | uint64 | 唯一的log id,用于问题定位 |
img_direction | false | int32 | detect_direction=true时返回。检测到的图像朝向,0 :正向; 1:逆时针旋转90度;2:逆时针旋转180度;3:逆时针旋转270度 |
results_num | true | uint32 | 识别结果数,表示results的元素个数 |
results | true | array[] | 识别结果数组 |
+words_type | true | string | 文字属性(手写、印刷),handwriting 手写,print 印刷 |
+words | true | array[] | 整行的识别结果数组。 |
++line_probability | false | array[] | line_probability=true时返回。识别结果中每一行的置信度值,包含average:行置信度平均值,min:行置信度最小值 |
+++average | false | float | 行置信度 |
+++min | false | float | 整行中单字的最低置信度 |
++word | true | float | 整行的识别结果 |
++words_location | true | array[] | 整行的矩形框坐标。位置数组(坐标0点为左上角) |
+++left | true | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++top | true | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++width | true | uint32 | 表示定位定位位置的长方形的宽度 |
+++height | true | uint32 | 表示位置的长方形的高度 |
+chars | false | array[] | result_type=small时返回。单字符结果数组。 |
++char | false | string | result_type=small时返回。每个单字的内容。 |
++chars_location | false | array[] | 每个单字的矩形框坐标。位置数组(坐标0点为左上角) |
+++left | false | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++top | false | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++width | false | uint32 | 表示定位定位位置的长方形的宽度 |
+++height | false | uint32 | 表示位置的长方形的高度 |
layouts_num | false | uint32 | 版面分析结果数,表示layout的元素个数 |
layouts | false | array[] | 文档版面信息数组,包含表格、图、段落文本、标题等标签;标签的坐标位置;段落文本和表格内文本内容对应的行序号ID |
+layout | false | string | 版面分析的标签结果。表格:table, 图:figure, 文本:text, 标题:title |
+layout_location | false | array[] | 文档版面信息标签的位置,四个顶点: 左上,右上,右下,左下 |
++x | false | uint32 | 水平坐标(坐标0点为左上角) |
++y | false | uint32 | 水平坐标(坐标0点为左上角) |
+layout_idx | false | array[] | 文档版面信息中的文本在results结果中的位置:版面文本标签对应的行序号ID为n,则此标签中的文本在results结果中第n+1条展示) |
仪器仪表盘读数识别
适用于不同品牌、不同型号的仪器仪表盘读数识别,广泛适用于各类血糖仪、血压仪、燃气表、电表等,可识别表盘上的数字、英文、符号,支持液晶屏、字轮表等表型。
1public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.meter(image, options);
8 System.out.println(res.toString(2));
9
10 // 参数为本地图片二进制数组
11 byte[] file = readImageFile(image);
12 res = client.meter(file, options);
13 System.out.println(res.toString(2));
14}
识别结果请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | true | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px。支持jpg/jpeg/png/bmp格式.注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) | |
probability | false | string | true/false | 是否返回每行识别结果的置信度。默认为false | |
poly_location | false | string | true/false | 位置信息返回形式,默认:false false:只给出识别结果所在长方形位置信息 true:除了默认的识别文字所在长方形的位置信息,还会给出文字所在区域的最小外接旋转矩形的4个点坐标信息 |
识别结果 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | true | uint64 | 唯一的log id,用于问题定位 |
words_result | true | array[] | 识别结果数组 |
words_result_num | true | uint32 | 识别结果数,表示words_result的元素个数 |
+words | true | string | 识别结果字符串 |
+location | true | array[] | 识别结果所在长方形位置信息 |
++left | true | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
++top | true | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | true | uint32 | 表示定位位置的长方形的宽度 |
++height | true | uint32 | 表示定位位置的长方形的高度 |
+probability | false | string | probability=true时存在。识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值 |
+poly_location | false | array[] | poly_location=true时存在。文字所在区域的外接四边形的4个点坐标信息 |
网络图片文字识别(含位置版)
支持识别艺术字体或背景复杂的文字内容,除文字信息外,还可返回每行文字的位置信息、行置信度,以及单字符内容和位置等。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.webimageLoc(image, options);
8 System.out.println(res.toString(2));
9
10 // 参数为本地图片二进制数组
11 byte[] file = readImageFile(image);
12 res = client.webimageLoc(file, options);
13 System.out.println(res.toString(2));
14 }
网络图片文字识别(含位置版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | true | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,像素乘积不超过20482048(10241024以内图像处理效果最佳)。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) | |
detect_direction | false | string | true/false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向 | |
probability | false | string | true/false | 是否返回每行识别结果的置信度。默认为false | |
poly_location | false | string | true/false | 是否返回文字所在区域的外接四边形的4个点坐标信息。默认为false | |
recognize_granularity | false | string | big/small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
识别结果 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | true | uint64 | 唯一的log id,用于问题定位 |
direction | false | int32 | 图像方向,当detect_direction=true时存在。检测到的图像朝向: 0 :正向; 1:逆时针旋转90度; 2:逆时针旋转180度; 3:逆时针旋转270度 |
words_result | true | array[] | 识别结果数组 |
words_result_num | true | uint32 | 识别结果数,表示words_result的元素个数 |
+words | true | string | 整行的识别结果 |
+location | true | object | 整行的矩形框坐标。位置数组(坐标0点为左上角) |
++left | true | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
++top | true | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | true | uint32 | 表示定位位置的长方形的宽度 |
++height | true | uint32 | 表示定位位置的长方形的高度 |
+probability | true | string | probability=true时存在。识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值 |
+poly_location | true | array[] | poly_location=true时存在。文字所在区域的外接矩形的4个点坐标信息 |
++x | true | uint32 | 水平坐标(坐标0点为左上角) |
++y | true | uint32 | 垂直坐标(坐标0点为左上角) |
+chars | false | array[] | 单字符结果,recognize_granularity=small时存在 |
++char | false | string | 单字符识别结果 |
++location | false | object | 每个单字的矩形框坐标。位置数组(坐标0点为左上角) |
+++left | false | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++top | false | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++width | false | uint32 | 表示定位定位位置的长方形的宽度 |
+++height | false | uint32 | 表示定位定位位置的长方形的高度 |
增值税发票识别
支持对增值税普票、专票、卷票、电子发票、区块链发票的所有字段进行结构化识别,包括发票基本信息、销售方及购买方信息、商品信息、价税信息等,其中五要素字段的识别准确率超过 99.9%; 同时,支持对增值税卷票的 21 个关键字段进行识别,包括发票类型、发票代码、发票号码、机打号码、机器编号、收款人、销售方名称、销售方纳税人识别号、开票日期、购买方名称、购买方纳税人识别号、项目、单价、数量、金额、税额、合计金额(小写)、合计金额(大写)、校验码、省、市,四要素字段的识别准确率可达95%。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.vatInvoice(image,EImgType.FILE, options);
8 System.out.println(res.toString(2));
9 // 参数为url
10 String image = "http://test.jpg";
11 JSONObject res = client.vatInvoice( image, EImgType.URL, options);
12 System.out.println(res.toString(2));
13 // 参数为本地pdf
14 String image = "test.pdf";
15 SONObject res = client.vatInvoice( image, EImgType.PDF, options);
16 System.out.println(res.toString(2));
17
18 // 参数为本地图片二进制数组
19 byte[] file = readImageFile(image);
20 res = client.vatInvoice(file, options);
21 System.out.println(res.toString(2));
22 }
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url或者pdf文件 |
imageType | 是 | EImgType | FILE,URL,PDF 表示image 类型 |
type | 否 | String | 可选参数,进行识别的增值税发票类型,默认为 normal,可缺省normal:可识别增值税普票、专票、电子发票roll:可识别增值税卷票 |
返回参数 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
InvoiceType | 是 | string | 发票种类 |
InvoiceTypeOrg | 是 | string | 发票名称 |
InvoiceCode | 是 | string | 发票代码 |
InvoiceNum | 是 | string | 发票号码 |
MachineNum | 是 | string | 机打号码。仅增值税卷票含有此参数 |
MachineCode | 是 | string | 机器编号。仅增值税卷票含有此参数 |
CheckCode | 否 | string | 校验码。增值税专票无此参数 |
InvoiceDate | 是 | string | 开票日期 |
PurchaserName | 是 | string | 购方名称 |
PurchaserRegisterNum | 是 | string | 购方纳税人识别号 |
PurchaserAddress | 是 | string | 购方地址及电话 |
PurchaserBank | 是 | string | 购方开户行及账号 |
Password | 是 | string | 密码区 |
Province | 是 | string | 省 |
City | 是 | string | 市 |
SheetNum | 是 | string | 联次 |
Agent | 是 | string | 是否代开 |
CommodityName | 是 | array[] | 货物名称 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityType | 是 | array[] | 规格型号 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityUnit | 是 | array[] | 单位 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityNum | 是 | array[] | 数量 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityPrice | 是 | array[] | 单价 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityAmount | 是 | array[] | 金额 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityTaxRate | 是 | array[] | 税率 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
CommodityTax | 是 | array[] | 税额 |
- row | 是 | uint32 | 行号 |
- word | 是 | string | 内容 |
SellerName | 是 | string | 销售方名称 |
SellerRegisterNum | 是 | string | 销售方纳税人识别号 |
SellerAddress | 是 | string | 销售方地址及电话 |
SellerBank | 是 | string | 销售方开户行及账号 |
TotalAmount | 是 | uint32 | 合计金额 |
TotalTax | 是 | uint32 | 合计税额 |
AmountInWords | 是 | string | 价税合计(大写) |
AmountInFiguers | 是 | uint32 | 价税合计(小写) |
Payee | 是 | string | 收款人 |
Checker | 是 | string | 复核 |
NoteDrawer | 是 | string | 开票人 |
Remarks | 是 | string | 备注 |
返回示例
1{
2 "log_id": "5425496231209218858",
3 "words_result_num": 29,
4 "words_result": {
5 "InvoiceNum": "14641426",
6 "SellerName": "上海易火广告传媒有限公司",
7 "CommodityTaxRate": [
8 {
9 "word": "6%",
10 "row": "1"
11 }
12 ],
13 "SellerBank": "中国银行南翔支行446863841354",
14 "Checker": ":沈园园",
15 "TotalAmount": "94339.62",
16 "CommodityAmount": [
17 {
18 "word": "94339.62",
19 "row": "1"
20 }
21 ],
22 "InvoiceDate": "2016年06月02日",
23 "CommodityTax": [
24 {
25 "word": "5660.38",
26 "row": "1"
27 }
28 ],
29 "PurchaserName": "百度时代网络技术(北京)有限公司",
30 "CommodityNum": [
31 {
32 "word": "",
33 "row": "1"
34 }
35 ],
36 "Province": "上海",
37 "City": "",
38 "SheetNum": "第三联",
39 "Agent": "否",
40 "PurchaserBank": "招商银行北京分行大屯路支行8661820285100030",
41 "Remarks": "告传",
42 "Password": "074/45781873408>/6>8>65*887676033/51+<5415>9/32--852>1+29<65>641-5>66<500>87/*-34<943359034>716905113*4242>",
43 "SellerAddress": ":嘉定区胜辛南路500号15幢1161室55033753",
44 "PurchaserAddress": "北京市海淀区东北旺西路8号中关村软件园17号楼二属A2010-59108001",
45 "InvoiceCode": "3100153130",
46 "CommodityUnit": [
47 {
48 "word": "",
49 "row": "1"
50 }
51 ],
52 "Payee": ":徐蓉",
53 "PurchaserRegisterNum": "110108787751579",
54 "CommodityPrice": [
55 {
56 "word": "",
57 "row": "1"
58 }
59 ],
60 "NoteDrawer": "沈园园",
61 "AmountInWords": "壹拾万圆整",
62 "AmountInFiguers": "100000.00",
63 "TotalTax": "5660.38",
64 "InvoiceType": "专用发票",
65 "SellerRegisterNum": "913101140659591751",
66 "CommodityName": [
67 {
68 "word": "信息服务费",
69 "row": "1"
70 }
71 ],
72 "CommodityType": [
73 {
74 "word": "",
75 "row": "1"
76 }
77 ]
78 }
79}
出租车票识别
支持识别全国各大城市出租车票的 16 个关键字段,包括发票号码、代码、车号、日期、总金额、燃油附加费、叫车服务费、省、市、单价、里程、上车时间、下车时间等。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.taxiReceipt(image,EImgType.FILE, options);
8 System.out.println(res.toString(2));
9
10 // 参数为url
11 String image = "http://test.jpg";
12 JSONObject res = client.taxiReceipt(image,EImgType.URl, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.taxiReceipt(file, options);
18 System.out.println(res.toString(2));
19 }
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
imageType | 是 | EImgType | FILE,URL 表示image 类型 |
返回参数 |
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
log_id | uint64 | 是 | 请求标识码,随机数,唯一。 |
words_result_num | uint32 | 是 | 识别结果数,表示words_result的元素个数 |
InvoiceCode | string | 是 | 发票代号 |
InvoiceNum | string | 是 | 发票号码 |
TaxiNum | string | 是 | 车牌号 |
Date | string | 是 | 日期 |
Time | string | 是 | 上下车时间 |
Fare | string | 是 | 总金额 |
FuelOilSurcharge | string | 是 | 燃油附加费 |
CallServiceSurcharge | string | 是 | 叫车服务费 |
Province | string | 是 | 省 |
City | string | 是 | 市 |
PricePerkm | string | 是 | 单价 |
Distance | string | 是 | 里程 |
返回示例
1{
2 "log_id":2034039896,
3 "words_result_num":6,
4 "words_result":
5 {
6 "Date":"2017-11-26",
7 "Fare":"¥153.30元",
8 "InvoiceCode":"111001681009",
9 "InvoiceNum":"90769610",
10 "TaxiNum":"BV2062",
11 "Time":"20:42-21:07",
12 "FuelOilSurcharge": "¥0.00",
13 "CallServiceSurcharge": "¥0.00",
14 "Province": "浙江省",
15 "City": "杭州市",
16 "PricePerkm": "2.50元/KM",
17 "Distance": "4.5KM"
18 }
19}
VIN码识别
支持对车辆挡风玻璃处的车架号码进行识别。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.vinCode(image,EImgType.FILE, options);
8 System.out.println(res.toString(2));
9
10 // 参数为url
11 String image = "http://test.jpg";
12 JSONObject res = client.vinCode(image,EImgType.URl, options);
13 System.out.println(res.toString(2));
14
15 // 参数为本地图片二进制数组
16 byte[] file = readImageFile(image);
17 res = client.vinCode(file, options);
18 System.out.println(res.toString(2));
19 }
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
imageType | 是 | EImgType | FILE,URL 表示image 类型 |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result | 是 | array[] | 定位和识别结果数组 |
location | 是 | object{} | 识别结果 |
words | 是 | string | VIN码识别结果 |
words_result_num | 是 | int | 识别结果数,表示words_result的元素个数 |
返回示例
1{
2 "log_id": 246589877,
3 "words_result": [
4 {
5 "location": {
6 "left": 124,
7 "top": 11,
8 "width": 58,
9 "height": 359
10 },
11 "words": "LFV2A11K8D4010942"
12 }
13 ],
14 "words_result_num": 1
15}
火车票识别
支持对红、蓝火车票的13个关键字段进行结构化识别,包括车票号码、始发站、目的站、车次、日期、票价、席别、姓名、座位号、身份证号、售站、序列号、时间。
1 public void sample(AipOcr client) {
2
3 // 传入可选参数调用接口
4 HashMap<String, String> options = new HashMap<String, String>();
5
6 // 参数为本地图片路径
7 String image = "test.jpg";
8 JSONObject res = client.trainTicket(image,EImgType.FILE, options);
9 System.out.println(res.toString(2));
10
11 // 参数为url
12 String image = "http://test.jpg";
13 JSONObject res = client.trainTicket(image,EImgType.URl, options);
14 System.out.println(res.toString(2));
15
16 // 参数为本地图片二进制数组
17 byte[] file = readImageFile(image);
18 res = client.trainTicket(file, options);
19 System.out.println(res.toString(2));
20 }
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
imageType | 是 | EImgType | FILE,URL 表示image 类型 |
返回参数 |
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
log_id | uint64 | 是 | 请求标识码,随机数,唯一。 |
ticket_num | string | 是 | 车票号 |
starting_station | string | 是 | 始发站 |
train_num | string | 是 | 车次号 |
destination_station | string | 是 | 到达站 |
date | string | 是 | 出发日期 |
ticket_rates | string | 是 | 车票金额 |
seat_category | string | 是 | 席别 |
name | string | 是 | 乘客姓名 |
id_num | string | 是 | 身份证号 |
serial_number | string | 是 | 序列号 |
sales_station | string | 是 | 售站 |
time | string | 是 | 时间 |
seat_num | string | 是 | 座位号 |
返回示例 |
1{
2 "log_id": "12317512659",
3 "direction": 1,
4 "words_result_num": 13,
5 "words_result": {
6 "id_num": "2302051998****156X",
7 "name": "裴一丽",
8 "ticket_rates": "¥54.5元",
9 "destination_station": "天津站",
10 "seat_category": "二等座",
11 "sales_station": "北京南",
12 "ticket_num": "F05706",
13 "seat_num": "02车03C号",
14 "time": "09:36",
15 "date": "2019年04月03日",
16 "serial_number": "10010300067846",
17 "train_num": "C255",
18 "starting_station": "北京南站"
19 }
20}
数字识别
对图片中的数字进行提取和识别,自动过滤非数字内容,仅返回数字内容及其位置信息,识别准确率超过99%。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 options.put("recognize_granularity","big");
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.numbers(image,options);
8 System.out.println(res.toString(2));
9
10 // 参数为本地图片二进制数组
11 byte[] file = readImageFile(image);
12 res = client.numbers(file, options);
13 System.out.println(res.toString(2));
14 }
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据 |
recognize_granularity | false | string | big、small |
detect_direction | false | string | true、false |
返回说明
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array[] | 定位和识别结果数组 |
location | 是 | object | 位置数组(坐标0点为左上角) |
left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | uint32 | 表示定位位置的长方形的宽度 |
height | 是 | uint32 | 表示定位位置的长方形的高度 |
words | 是 | string | 识别结果字符串 |
chars | 否 | array[] | 单字符结果,recognize_granularity=small时存在 |
location | 是 | object{} | 位置数组(坐标0点为左上角) |
left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | uint32 | 表示定位定位位置的长方形的宽度 |
height | 是 | uint32 | 表示位置的长方形的高度 |
char | 是 | string | 单字符识别结果 |
返回示例
1{
2 "log_id": 620759800,
3 "words_result": [
4 {
5 "location": {
6 "left": 56,
7 "top": 0,
8 "width": 21,
9 "height": 210
10 },
11 "words": "3"
12 }
13 ],
14 "words_result_num": 1
15}
二维码识别
对图片中的二维码、条形码进行检测和识别,返回存储的文字信息。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 // 参数为二进制数组
5 byte[] file = readFile("test.jpg");
6 res = client.qrcode(file, options);
7 System.out.println(res.toString(2));
8
9 // 参数图片url
10 String url = "http://localhost/test.jpg"
11 res = client.qrcodeUrl(url, options);
12 System.out.println(res.toString(2));
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
codes_result_num | 是 | uint32 | 识别结果数,表示codes_result的元素个数 |
codes_result | 是 | array[] | 定位和识别结果数组 |
-type | 是 | string | 识别码类型条码类型包括:9种条形码(UPC_A、UPC_E、EAN_13、EAN_8、CODE_39、CODE_93、CODE_128、ITF、CODABAR),4种二维码(QR_CODE、DATA_MATRIX、AZTEC、PDF_417) |
-text | 是 | string | 条形码识别内容,暂时只限于识别中英文结果 |
返回示例
1{
2 "log_id": 863402790,
3 "codes_result": [
4 {
5 "type": "QR_CODE",
6 "text": [
7 "中国",
8 "北京"
9 ]
10 }
11 ],
12 "codes_result_num": 1
13}
14示例2(多个图的情况):
15{
16 "log_id": 1508509437,
17 "codes_result": [
18 {
19 "type": "QR_CODE",
20 "text": [
21 "HTTP://Q8R.HK/YELZ0"
22 ]
23 },
24 {
25 "type": "PDF_417",
26 "text": [
27 "PDF417偼丄TL-30偱撉傒庢傝壜擻偱偡丅"
28 ]
29 },
30 {
31 "type": "CODABAR",
32 "text": [
33 "000800"
34 ]
35 },
36 {
37 "type": "CODE_39",
38 "text": [
39 "1234567890"
40 ]
41 },
42 {
43 "type": "AZTEC",
44 "text": [
45 "www.tec-it.com"
46 ]
47 },
48 {
49 "type": "DATA_MATRIX",
50 "text": [
51 "Wikipedia, the free encyclopedia"
52 ]
53 },
54 {
55 "type": "CODE_93",
56 "text": [
57 "123456789"
58 ]
59 },
60 {
61 "type": "CODE_128",
62 "text": [
63 "50090500019191"
64 ]
65 },
66 {
67 "type": "EAN_8",
68 "text": [
69 "12345670"
70 ]
71 },
72 {
73 "type": "EAN_13",
74 "text": [
75 "6901234567892"
76 ]
77 },
78 {
79 "type": "UPC_E",
80 "text": [
81 "01234565"
82 ]
83 }
84 ],
85 "codes_result_num": 11
86}
机动车销售发票
支持对机动车销售发票的26个关键字段进行结构化识别,包括发票代码、发票号码、开票日期、机器编号、购买方名称、购买方身份证号码/组织机构代码、车辆类型、厂牌型号、产地、合格证号、发动机号码、车架号码、价税合计、价税合计小写、销货单位名称、电话、纳税人识别号、账号、地址、开户银行、税率、税额、主管税务机关及代码、不含税价格、限乘人数。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 // 参数为二进制数组
5 byte[] file = readFile("test.jpg");
6 res = client.vehicleInvoice(file, options);
7 System.out.println(res.toString(2));
8
9 // 参数图片url
10 String url = "http://localhost/test.jpg"
11 res = client.vehicleInvoiceUrl(url, options);
12 System.out.println(res.toString(2));
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array() | 识别结果数组 |
InvoiceCode | 是 | string | 发票代码/机打代码 |
InvoiceNum | 是 | string | 发票号码/机打号码 |
InvoiceDate | 是 | string | 开票日期 |
MachineCode | 是 | string | 机器编号 |
Purchaser | 是 | string | 购买方名称 |
PurchaserCode | 是 | string | 购买方身份证号码/组织机构代码 |
VehicleType | 是 | string | 车辆类型 |
ManuModel | 是 | string | 厂牌型号 |
Origin | 是 | string | 产地 |
CertificateNum | 是 | string | 合格证号 |
EngineNum | 是 | string | 发动机号码 |
VinNum | 是 | string | 车架号码 |
PriceTax | 是 | string | 价税合计 |
PriceTaxLow | 是 | string | 价税合计小写 |
Saler | 是 | string | 销货单位名称 |
SalerPhone | 是 | string | 销货单位电话 |
SalerCode | 是 | string | 销货单位纳税人识别号 |
SalerAccountNum | 是 | string | 销货单位账号 |
SalerAddress | 是 | string | 销货单位地址 |
SalerBank | 是 | string | 销货单位开户银行 |
TaxRate | 是 | string | 税率 |
Tax | 是 | string | 税额 |
TaxAuthor | 是 | string | 主管税务机关 |
TaxAuthorCode | 是 | string | 主管税务机关代码 |
Price | 是 | string | 不含税价格 |
LimitPassenger | 是 | string | 限乘人数 |
返回示例
1{
2 "log_id": 283449393728149457,
3 "words_result_num": 26,
4 "words_result": {
5 "InvoiceNum": "00875336",
6 "Saler": "深圳市新能源汽车销售有限公司",
7 "LimitPassenger": "5",
8 "MachineCode": "669745967911",
9 "VinNum": "LJLGTCRP1J4007581",
10 "TaxRate": "16%",
11 "PriceTaxLow": "106100.00",
12 "InvoiceDate": "2018-11-29",
13 "Price": "¥91465.52",
14 "SalerBank": "中国工商银行股份有限公司深圳岭园支行",
15 "TaxAuthor": "国家锐务总局深圳市龙岗区税务局第五税务所",
16 "ManuModel": "江淮牌HFC7007EYBD6",
17 "CertificateNum": "WCH0794J0976801",
18 "Purchaser": "苏子潇",
19 "VehicleType": "纯电动轿车",
20 "InvoiceCode": "14975047560",
21 "PriceTax": "壹拾万陆仟壹佰圆整",
22 "SalerPhone": "0755-83489306",
23 "SalerAddress": "深圳市龙岗区龙岗街道百世国际汽车城",
24 "Origin": "安徽省合肥市",
25 "EngineNum": "18958407",
26 "Tax": "14634.48",
27 "PurchaserCode": "5135934475603742222",
28 "TaxAuthorCode": "14037589413",
29 "SalerAccountNum": "中国工商银行股份有限公司深圳岭园支行",
30 "SalerCode": "9144928346458292278H"
31 }
32}
车辆合格证
支持对车辆合格证的23个关键字段进行结构化识别,包括合格证编号、发证日期、车辆制造企业名、车辆品牌、车辆名称、车辆型号、车架号、车身颜色、发动机型号、发动机号、燃料种类、排量、功率、排放标准、轮胎数、轴距、轴数、转向形式、总质量、整备质量、驾驶室准乘人数、最高设计车速、车辆制造日期。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 // 参数为二进制数组
5 byte[] file = readFile("test.jpg");
6 res = client.vehicleCertificate(file, options);
7 System.out.println(res.toString(2));
8
9 // 参数图片url
10 String url = "http://localhost/test.jpg"
11 res = client.vehicleCertificateUrl(url, options);
12 System.out.println(res.toString(2));
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array() | 识别结果数组 |
CertificationNo | 是 | string | 合格证编号 |
CertificateDate | 是 | string | 发证日期 |
Manufacturer | 是 | string | 车辆制造企业名 |
CarBrand | 是 | string | 车辆品牌 |
CarName | 是 | string | 车辆名称 |
CarModel | 是 | string | 车辆型号 |
VinNo | 是 | string | 车架号 |
CarColor | 是 | string | 车身颜色 |
EngineType | 是 | string | 发动机型号 |
EngineNo | 是 | string | 发动机号 |
FuelType | 是 | string | 燃料种类 |
Displacement | 是 | string | 排量 |
Power | 是 | string | 功率 |
EmissionStandard | 是 | string | 排放标准 |
TyreNum | 是 | string | 轮胎数 |
Wheelbase | 是 | string | 轴距 |
AxleNum | 是 | string | 轴数 |
SteeringType | 是 | string | 转向形式 |
TotalWeight | 是 | string | 总质量 |
SaddleMass | 是 | string | 整备质量 |
LimitPassenger | 是 | string | 驾驶室准乘人数 |
SpeedLimit | 是 | string | 最高设计车速 |
ManufactureDate | 是 | string | 车辆制造日期 |
返回示例
1{
2 "log_id": 14814098736243057,
3 "words_result_num": 23,
4 "words_result": {
5 "ManufactureDate": "2016年10月13日",
6 "CarColor": "红",
7 "LimitPassenger": "2",
8 "EngineType": "WP12.460E50",
9 "TotalWeight": "25000",
10 "Power": "338",
11 "CertificationNo": "WEK29JX98645437",
12 "FuelType": "汽油",
13 "Manufacturer": "陕西汽车集团有限责任公司",
14 "SteeringType": "方向盘",
15 "Wheelbase": "3175+1350",
16 "SpeedLimit": "105",
17 "EngineNo": "1418K129178",
18 "SaddleMass": "8600",
19 "AxleNum": "3",
20 "CarModel": "SX4250MC4",
21 "VinNo": "LZGJHYD83JX197344",
22 "CarBrand": "陕汽牌",
23 "EmissionStandard": "GB17691-2005国V,GB3847-2005",
24 "Displacement": "11596",
25 "CertificateDate": "2018年11月28日",
26 "CarName": "牵引汽车",
27 "TyreNum": "10"
28 }
29}
户口本识别
支持对户口本内常住人口登记卡的全部 22 个字段进行结构化识别,包括户号、姓名、与户主关系、性别、出生地、民族、出生日期、身份证号、本市县其他住址、曾用名、籍贯、宗教信仰、身高、血型、文化程度、婚姻状况、兵役状况、服务处所、职业、何时由何地迁往本市、何时由何地迁往本址、登记日期。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 // 参数为二进制数组
5 byte[] file = readFile("test.jpg");
6 res = client.householdRegister(file, options);
7 System.out.println(res.toString(2));
8
9 // 参数图片url
10 String url = "http://localhost/test.jpg"
11 res = client.householdRegisterUrl(url, options);
12 System.out.println(res.toString(2));
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和image二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | int | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
Name | 是 | object{} | 姓名 |
+ words | 是 | string | 所属字段的具体内容,以下各字段均含有此元素 |
Relationship | 是 | object{} | 户主或与户主关系 |
Sex | 是 | object{} | 性别 |
BirthAddress | 是 | object{} | 出生地 |
Nation | 是 | object{} | 民族 |
Birthday | 是 | object{} | 生日 |
CardNo | 是 | object{} | 身份证号 |
HouseholdNum | 是 | object{} | 户号 |
FormerName | 是 | object{} | 曾用名 |
Hometown | 是 | object{} | 籍贯 |
OtherAddress | 是 | object{} | 本市(县)其他住址 |
Belief | 是 | object{} | 宗教信仰 |
Height | 是 | object{} | 身高 |
BloodType | 是 | object{} | 血型 |
Education | 是 | object{} | 文化程度 |
MaritalStatus | 是 | object{} | 婚姻状况 |
VeteranStatus | 是 | object{} | 兵役状况 |
WorkAddress | 是 | object{} | 服务处所 |
Career | 是 | object{} | 职业 |
WWToCity | 是 | object{} | 何时由何地迁来本市(县) |
WWHere | 是 | object{} | 何时由何地迁往本址 |
Date | 是 | object{} | 登记日期 |
返回示例
1 {
2 "log_id": 1301870459,
3 "words_result": {
4 "BirthAddress": {
5 "words": "河南洛阳市郊区"
6 },
7 "Birthday": {
8 "words": "2016-07-28"
9 },
10 "CardNo": {
11 "words": "410311201607282825"
12 },
13 "Name": {
14 "words": "孙翌晨"
15 },
16 "Nation": {
17 "words": "汉族"
18 },
19 "Relationship": {
20 "words": "户主"
21 },
22 "Sex": {
23 "words": "男"
24 },
25 },
26 "words_result_num": 7
27}
手写文字识别
支持对图片中的手写中文、手写数字进行检测和识别,针对不规则的手写字体进行专项优化,识别准确率可达90%以上。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, Object> options = new HashMap<String, Object>();
4 options.put("recognize_granularity","big");
5 options.put("probability",false);
6 options.put("detect_direction",true);
7 // 参数为二进制数组
8 byte[] file = readFile("test.jpg");
9 res = client.handwriting(file, options);
10 System.out.println(res.toString(2));
11
12 // 参数图片url
13 String url = "http://localhost/test.jpg"
14 res = client.handwritingUrl(url, options);
15 System.out.println(res.toString(2));
16 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
recognize_granularity | 否 | string | big、small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
probability | 否 | string | true/false | 是否返回识别结果中每一行的置信度,默认为false,不返回置信度 |
detect_direction | 否 | string | true/false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: true:检测朝向; false:不检测朝向 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array[] | 定位和识别结果数组 |
location | 是 | object{} | 位置数组(坐标0点为左上角) |
left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | uint32 | 表示定位位置的长方形的宽度 |
height | 是 | uint32 | 表示定位位置的长方形的高度 |
words | 是 | string | 识别结果字符串 |
chars | 否 | array[] | 单字符结果,recognize_granularity=small时存在 |
location | 是 | object{} | 位置数组(坐标0点为左上角) |
left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | uint32 | 表示定位定位位置的长方形的宽度 |
height | 是 | uint32 | 表示位置的长方形的高度 |
char | 是 | string | 单字符识别结果 |
probability | 否 | float | 当请求参数 probability=true 时返回该字段,表示识别结果中每一行的置信度值,包含:- average: 行置信度平均值- variance:行置信度方差- min:行置信度最小值 |
direction | 否 | int32 | 图像方向,当detect_direction=true时存在 -1:未定义, 0:正向, 1: 逆时针90度, 2:逆时针180度, 3:逆时针270度 |
返回示例
1 {
2 "log_id": 620759800,
3 "words_result": [
4 {
5 "location": {
6 "left": 56,
7 "top": 0,
8 "width": 21,
9 "height": 210
10 },
11 "words": "3"
12 }
13 ],
14 "words_result_num": 1
15 }
飞机行程单识别
支持对飞机行程单的24个字段进行结构化识别,包括电子客票号、印刷序号、姓名、始发站、目的站、航班号、日期、时间、票价、身份证号、承运人、民航发展基金、保险费、燃油附加费、其他税费、合计金额、填开日期、订票渠道、客票级别、座位等级、销售单位号、签注、免费行李、验证码。同时,支持单张行程单上的多航班信息识别。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, Object> options = new HashMap<String, Object>();
4 options.put("multi_detect",true)
5 // 参数为二进制数组
6 byte[] file = readFile("test.jpg");
7 res = client.airTicket(file, options);
8 System.out.println(res.toString(2));
9
10 // 参数图片url
11 String url = "http://localhost/test.jpg"
12 res = client.airTicketUrl(url, options);
13 System.out.println(res.toString(2));
14 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
multi_detect | 否 | bool | true/false | 控制是否开启多航班信息识别功能,默认值:false- true:开启多航班信息识别功能,开启后返回结果中对应字段格式将改为数组类型- false: 不开启,仅识别单一航班信息 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
name | 是 | string | 姓名 |
starting_station | 是 | string | 始发站 |
destination_station | 是 | string | 目的站 |
flight | 是 | string | 航班号 |
date | 是 | string | 日期 |
ticket_number | 是 | string | 电子客票号码 |
fare | 是 | string | 票价 |
dev_fund | 是 | string | 民航发展基金/基建费 |
fuel_surcharge | 是 | string | 燃油附加费 |
other_tax | 是 | string | 其他税费 |
ticket_rates | 是 | string | 合计金额 |
issued_date | 是 | string | 填开日期 |
id_num | 是 | string | 身份证号 |
carrier | 是 | string | 承运人 |
time | 是 | string | 时间 |
issued_by | 是 | string | 订票渠道 |
serial_number | 是 | string | 印刷序号 |
insurance | 是 | string | 保险费 |
fare_basis | 是 | string | 客票级别 |
class | 是 | string | 座位等级 |
agent_code | 是 | string | 销售单位号 |
endorsement | 是 | string | 签注 |
allow | 是 | string | 免费行李 |
ck | 是 | string | 验证码 |
返回示例
1// 识别单航班信息(multi_detect=false,或参数缺省)
2{
3 "log_id": 7306800033425229106,
4 "direction": 0,
5 "words_result_num": 18,
6 "words_result": {
7 "insurance": "20.00",
8 "date": "2019-10-22",
9 "allow": "20K",
10 "flight": "CA6589",
11 "issued_by": "中国国际航空服务有限公司",
12 "starting_station": "武汉",
13 "fare": "260.00",
14 "endorsement": "不得签转改期退转",
15 "ticket_rates": "350.00",
16 "ck": "5866",
17 "serial_number": "51523588676",
18 "ticket_number": "7843708871196",
19 "fuel_surcharge": "EXEMPT",
20 "carrier": "南航",
21 "issued_date": "2019-10-30",
22 "other_tax": "",
23 "fare_basis": "NREOW",
24 "id_num": "411201123909020877",
25 "destination_station": "合肥",
26 "name": "郭达",
27 "agent_code": "BJS19197300025",
28 "time": "21:25",
29 "class": "N",
30 "dev_fund": "50.00"
31 }
32}
33
34// 识别多航班信息(multi_detect=true)
35{
36 "words_result": {
37 "insurance": [
38 {
39 "word": "XXX"
40 }
41 ],
42 "date": [
43 {
44 "word": "2019-10-18"
45 },
46 {
47 "word": "2019-10-21"
48 }
49 ],
50 "flight": [
51 {
52 "word": "CZ3565"
53 },
54 {
55 "word": "CZ3566"
56 }
57 ],
58 "issued_by": [
59 {
60 "word": "上海携程旅行社有限公司"
61 }
62 ],
63 "starting_station": [
64 {
65 "word": "北京"
66 }
67 ],
68 "fare": [
69 {
70 "word": "1080.00"
71 }
72 ],
73 "ticket_rates": [
74 {
75 "word": "1420.00"
76 }
77 ],
78 "serial_number": [
79 {
80 "word": "45956029770"
81 }
82 ],
83 "ticket_number": [
84 {
85 "word": "7849648364314"
86 }
87 ],
88 "fuel_surcharge": [
89 {
90 "word": "240.00"
91 }
92 ],
93 "carrier": [
94 {
95 "word": "南航"
96 },
97 {
98 "word": "南航"
99 }
100 ],
101 "issued_date": [
102 {
103 "word": "2019-09-18"
104 }
105 ],
106 "other_tax": [],
107 "id_num": [
108 {
109 "word": "0789654700"
110 }
111 ],
112 "destination_station": [
113 {
114 "word": "深圳"
115 },
116 {
117 "word": "北京"
118 }
119 ],
120 "name": [
121 {
122 "word": "姚佳"
123 }
124 ],
125 "time": [
126 {
127 "word": "13:55"
128 },
129 {
130 "word": "16:30"
131 }
132 ],
133 "dev_fund": [
134 {
135 "word": "100.00"
136 }
137 ]
138 },
139 "log_id": "1280814270572920832",
140 "words_result_num": 18
141}
通用机打发票
支持对国家/地方税务局发行的横/竖版通用机打发票的23个关键字段进行结构化识别,包括发票类型、发票号码、发票代码、开票日期、合计金额大写、合计金额小写、商品名称、商品单位、商品单价、商品数量、商品金额、机打代码、机打号码、校验码、销售方名称、销售方纳税人识别号、购买方名称、购买方纳税人识别号、合计税额等。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, Object> options = new HashMap<String, Object>();
4 options.put("location",false);
5 // 参数为二进制数组
6 byte[] file = readFile("test.jpg");
7 res = client.invoice(file, options);
8 System.out.println(res.toString(2));
9
10 // 参数图片url
11 String url = "http://localhost/test.jpg"
12 res = client.invoiceUrl(url, options);
13 System.out.println(res.toString(2));
14 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
location | 否 | string | true/false | 是否输出位置信息,true:输出位置信息,false:不输出位置信息,默认false |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
InvoiceType | 否 | string | 发票类型 |
InvoiceCode | 否 | string | 发票代码 |
InvoiceNum | 否 | string | 发票号码 |
InvoiceDate | 否 | string | 开票日期 |
AmountInFiguers | 否 | string | 合计金额小写 |
AmountInWords | 否 | string | 合计金额大写 |
CommodityName | 否 | string | 商品名称 |
CommodityUnit | 否 | string | 商品单位 |
CommodityPrice | 否 | string | 商品单价 |
CommodityNum | 否 | string | 商品数量 |
CommodityAmount | 否 | string | 商品金额 |
MachineCode | 否 | string | 机打代码 |
MachineNum | 否 | string | 机打号码 |
CheckCode | 否 | string | 校验码 |
SellerName | 否 | string | 销售方名称 |
SellerRegisterNum | 否 | string | 销售方纳税人识别号 |
PurchaserName | 否 | string | 购买方名称 |
PurchaserRegisterNum | 否 | string | 购买方纳税人识别号 |
TotalTax | 否 | string | 合计税额 |
Province | 否 | string | 省 |
City | 否 | string | 市 |
Time | 否 | string | 时间 |
SheetNum | 否 | string | 联次 |
返回示例
1{
2 "log_id": 4423022131715883558,
3 "direction": 0,
4 "words_result_num": 22,
5 "words_result": {
6 "City": "",
7 "InvoiceNum": "01445096",
8 "SellerName": "百度餐饮店",
9 "IndustrSort": "生活服务",
10 "Province": "广东省",
11 "CommodityAmount": [
12 {
13 "word": "183.00",
14 "row": "1"
15 }
16 ],
17 "InvoiceDate": "2020年07月28日",
18 "PurchaserName": "中信建投证券股份有限公司",
19 "CommodityNum": [],
20 "InvoiceCode": "144001901511",
21 "CommodityUnit": [],
22 "SheetNum": "",
23 "PurchaserRegisterNum": "9144223008453480X9",
24 "Time": "",
25 "CommodityPrice": [],
26 "AmountInFiguers": "183.00",
27 "AmountInWords": "壹佰捌拾叁元整",
28 "CheckCode": "61042119820421061301",
29 "TotalTax": "183.00",
30 "InvoiceType": "广东通用机打发票",
31 "SellerRegisterNum": "61042119820421061301",
32 "CommodityName": [
33 {
34 "word": "餐费",
35 "row": "1"
36 }
37 ]
38 }
39}
护照识别
支持对中国大陆护照个人资料页所有15个字段进行结构化识别,包括国家码、护照号、姓名、姓名拼音、性别、出生地点、出生日期、签发地点(不支持境外签发地)、签发日期、有效期、签发机关、护照类型、国籍、MRZCode1、MRZCode2。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4 // 参数为二进制数组
5 byte[] file = readFile("test.jpg");
6 res = client.passport(file, options);
7 System.out.println(res.toString(2));
8
9 // 参数图片url
10 String url = "http://localhost/test.jpg"
11 res = client.passportUrl(url, options);
12 System.out.println(res.toString(2));
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
-location | 是 | uint32 | 水平坐标 |
-words | 是 | string | 识别内容 |
返回示例
1{
2 "log_id": 7377468409496932872,
3 "words_result_num": 14,
4 "words_result": {
5 "国家码": {
6 "location": {
7 "width": 59,
8 "top": 200,
9 "left": 762,
10 "height": 26
11 },
12 "words": "CHN"
13 },
14 "护照签发地点": {
15 "location": {
16 "width": 236,
17 "top": 505,
18 "left": 558,
19 "height": 43
20 },
21 "words": "山东/SHANDONG"
22 },
23 "MRZCode2": {
24 "location": {
25 "width": 1252,
26 "top": 797,
27 "left": 145,
28 "height": 88
29 },
30 "words": "E898657303CHNSDMO7O2<<<<<<<<<<<<<"
31 },
32 "有效期至": {
33 "location": {
34 "width": 287,
35 "top": 528,
36 "left": 955,
37 "height": 46
38 },
39 "words": "20261004"
40 },
41 "签发机关": {
42 "location": {
43 "width": 271,
44 "top": 583,
45 "left": 552,
46 "height": 42
47 },
48 "words": "出入境管理局"
49 },
50 "MRZCode1": {
51 "location": {
52 "width": 1201,
53 "top": 781,
54 "left": 162,
55 "height": 45
56 },
57 "words": "PONSUN<<JIAJIA<<<<<<<<<<<<<<<<<<<<<<<<<<"
58 },
59 "护照号码": {
60 "location": {
61 "width": 237,
62 "top": 215,
63 "left": 994,
64 "height": 48
65 },
66 "words": "E89865730"
67 },
68 "签发日期": {
69 "location": {
70 "width": 279,
71 "top": 453,
72 "left": 955,
73 "height": 46
74 },
75 "words": "20161005"
76 },
77 "出生地点": {
78 "location": {
79 "width": 216,
80 "top": 429,
81 "left": 564,
82 "height": 43
83 },
84 "words": "山东/SHANDONG"
85 },
86 "姓名": {
87 "location": {
88 "width": 159,
89 "top": 247,
90 "left": 581,
91 "height": 34
92 },
93 "words": "孙嘉佳"
94 },
95 "姓名拼音": {
96 "location": {
97 "width": 229,
98 "top": 279,
99 "left": 578,
100 "height": 41
101 },
102 "words": "SUN,JIAJIA"
103 },
104 "国籍": {
105 "location": {
106 "width": 209,
107 "top": 366,
108 "left": 695,
109 "height": 42
110 },
111 "words": "中国/CHINESE"
112 },
113 "生日": {
114 "location": {
115 "width": 202,
116 "top": 382,
117 "left": 950,
118 "height": 39
119 },
120 "words": "19950723"
121 },
122 "性别": {
123 "location": {
124 "width": 73,
125 "top": 357,
126 "left": 570,
127 "height": 34
128 },
129 "words": "男/M"
130 }
131 }
132}
网约车行程单识别
对各大主要服务商的网约车行程单进行结构化识别,包括滴滴打车、花小猪打车、高德地图、曹操出行、阳光出行,支持识别服务商、行程开始时间、行程结束时间、车型、总金额等16 个关键字段。
1public void Demo() {
2 AipOcr client=new AipOcr("appid","ak","sk");
3 HashMap<String, Object> options = new HashMap<>();
4 string url = "https//www.x.com/sample.jpg";
5 byte[] image = readFile("文件或图片路径");
6 byte[] pdf_file =readFile("pdf路径") ;
7
8 JSONObject res = null;
9 // 调用网约车行程单识别
10 res = client.OnlineTaxiItinerary(image);
11 res = client.OnlineTaxiItineraryUrl(url);
12 res = client.OnlineTaxiItineraryPdf(pdf_file,null);
13
14 // 如果有可选参数
15 options.put("pdf_file_num", 1);
16 res = client.onlineTaxiItineraryPdf(pdf_file, options);
17 System.out.println(res.toString(2));
18}
请求参数详情
参数 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 和url二选一 | string | 图像数据,base64编码后进行urlencode,base64编码去除编码头(data:image/jpeg;base64),要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效,请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
返回参数详情 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object | 识别结果 |
+ ServiceProvider | 是 | string | 服务商 |
+ StartTime | 是 | string | 行程开始时间 |
+ EndTime | 是 | string | 行程结束时间 |
+ Phone | 是 | string | 行程人手机号 |
+ ApplicationDate | 是 | string | 申请日期 |
+ TotalFare | 是 | string | 总金额 |
+ ItemNum | 是 | array | 行程信息中包含的行程数量 |
+ Items | 是 | array | 行程信息 |
++ ItemId | 是 | string | 行程信息的对应序号 |
++ PickupTime | 是 | string | 上车时间 |
++ PickupDate | 是 | string | 上车日期 |
++ CarType | 是 | string | 车型 |
++ Distance | 是 | string | 里程 |
++ StartPlace | 是 | string | 起点 |
++ DestinationPlace | 是 | string | 终点 |
++ City | 是 | string | 城市 |
++ Fare | 是 | string | 金额 |
pdf_file_size | 否 | string | 传入PDF文件的总页数,当 pdf_file 参数有效时返回该字段 |
返回示例
1{
2 "log_id": 1385196013945356288,
3 "words_result_num": 7
4 "words_result": {
5 "TotalFare": "2316",
6 "EndTime": "2020-07-30 19:00",
7 "Phone": "13000000000",
8 "ServiceProvider": "滴滴企业版",
9 "StartTime": "2020-07-01 16:00",
10 "ApplicationDate": "2017-12-08",
11 "ItemId": "3"
12 "items": [
13 {
14 "ItemId": "1",
15 "StartPlace": "鱼化寨地铁-D口",
16 "PickupTime": "16:00",
17 "CarType": "快车",
18 "City": "西安市",
19 "Distance": "9.7",
20 "PickupDate": "20-07-01",
21 "DestinationPlace": "创新港",
22 "Fare": "20.86"
23 },
24 {
25 "ItemId": "2",
26 "StartPlace": "科学园东门",
27 "PickupTime": "14:56",
28 "CarType": "快车",
29 "City": "西安市",
30 "Distance": "91",
31 "PickupDate": "20-07-02",
32 "DestinationPlace": "鱼化寨地铁站",
33 "Fare": "18.58"
34 },
35 {
36 "ItemId": "3",
37 "StartPlace": "中俄丝路创新园东门",
38 "PickupTime": "19:00",
39 "CarType": "快车",
40 "City": "西安市",
41 "Distance": "9.1",
42 "PickupDate": "20-07-30",
43 "DestinationPlace": "新门地铁站",
44 "Fare": "20.38"
45 },
46 ],
47 },
48}
磅单识别
结构化识别磅单的车牌号、打印时间、毛重、皮重、净重、发货单位、收货单位、单号8个关键字段,现阶段仅支持识别印刷体磅单。
1public void Demo() {
2 AipOcr client=new AipOcr("appid","ak","sk");
3 HashMap<String, Object> options = new HashMap<>();
4 string url = "https//www.x.com/sample.jpg";
5 byte[] pdf_file = ;
6 byte[] image = readFile("文件或图片路径");
7 JSONObject res = null; // 调用磅单识别
8 res = client.WeightNote(image,null);
9 res = client.WeightNoteUrl(url,null);
10 res = client.WeightNotePdf(pdf_file,null);
11
12 // 如果有可选参数
13 options.put("pdf_file_num", 1);
14 options.put("probability", false);
15
16 res = client.weightNote(image, options);
17 System.out.println(res.toString(2));
18
19 res = client.weightNoteUrl(url, options);
20 System.out.println(res.toString(2));
21
22 res = client.weightNotePdf(pdf_file, options);
23 System.out.println(res.toString(2));
24}
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和 url/pdf_file 三选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和 image/pdf_file 三选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | - | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | - | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
probability | 否 | true/false | - | 是否返回字段识别结果的置信度,默认为 false,可缺省- false:不返回字段识别结果的置信度- true:返回字段识别结果的置信度,包括字段识别结果中各字符置信度的平均值(average)和最小值(min) |
返回参数详情
字段 | 是否必输出 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 调用日志id,用于问题定位 |
words_result | 是 | object | 识别结果 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
+ PlateNum | 是 | object | 车牌号 |
+ PrintTime | 是 | object | 打印时间 |
+ CrossWeight | 是 | object | 毛重 |
+ TareWeight | 是 | object | 皮重 |
+ NetWeight | 是 | object | 净重 |
+ SendingCompany | 是 | object | 发货单位 |
+ ReceivingCompany | 是 | object | 收货单位 |
+ DeliveryNumber | 是 | object | 单号 |
++ word | 是 | string | 字段识别结果,以上各字段均包含此参数 |
++ probability | 否 | object | 字段识别结果置信度,当请求参数 probability=true 时,以上各字段均包含此参数 |
+++ average | 否 | float | 字段识别结果中各字符的置信度平均值 |
+++ min | 否 | float | 字段识别结果中各字符的置信度最小值 |
pdf_file_size | 否 | string | 传入PDF文件的总页数,当 pdf_file 参数有效时返回该字段 |
返回示例 |
1{
2 "words_result": [
3 {
4 "TareWeight": [
5 {
6 "word": "14.20"
7 }
8 ],
9 "CrossWeight": [
10 {
11 "word": "50.70"
12 }
13 ],
14 "PlateNum": [
15 {
16 "word": "京A12356"
17 }
18 ],
19 "SendingCompany": [
20 {
21 "word": "宣化县耿矿煤业有限公司"
22 }
23 ],
24 "DeliveryNumber": [
25 {
26 "word": "278933000"
27 }
28 ],
29 "ReceivingCompany": [
30 {
31 "word": "宁夏市京裕达实业公司"
32 }
33 ],
34 "PrintTime": [
35 {
36 "word": "2020年1月1日"
37 }
38 ],
39 "NetWeight": [
40 {
41 "word": "36.50"
42 }
43 ]
44 }
45 ],
46 "words_result_num": 1,
47 "log_id": 1428311410130160734
48}
医疗费用明细识别
支持识别全国医疗费用明细的姓名、日期、病人ID、总金额等关键字段,支持识别费用明细项目清单,包含项目类型、项目名称、单价、数量、规格、金额,其中北京地区识别效果最佳。
1public void Demo() {
2 AipOcr client=new AipOcr("appid","ak","sk");
3 HashMap<String, Object> options = new HashMap<>();
4 byte[] image = readFile("文件或图片路径");
5 string url = "https//www.x.com/sample.jpg";
6
7 JSONObject res = null;
8 // 调用医疗费用明细识别
9 res = client.MedicalDetail(image,null);
10 res = client.MedicalDetailUrl(url,null);
11
12 // 如果有可选参数
13 options.put("probability", false);
14
15 res = client.medicalDetail(image, options);
16 System.out.println(res.toString(2));
17
18 res = client.medicalDetailUrl(url, options);
19 System.out.println(res.toString(2));
20}
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过10M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过10M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
location | 否 | true/false | - | 是否返回字段的位置信息,默认为 false,可缺省- false:不返回字段位置信息- true:返回字段的位置信息,包括上边距(top)、左边距(left)、宽度(width)、高度(height) |
probability | 否 | true/false | - | 是否返回字段识别结果的置信度,默认为 false,可缺省- false:不返回字段识别结果的置信度- true:返回字段识别结果的置信度,包括字段识别结果中各字符置信度的平均值(average)和最小值(min) |
返回参数详情
字段 | 是否必输出 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 调用日志id,用于问题定位 |
words_result | 是 | object | 识别结果 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
+ Name | 是 | object | 姓名 |
+ Date | 是 | object | 日期 |
+ PatientID | 是 | object | 病人ID |
+ TotalAmount | 是 | object | 总金额 |
+ word | 是 | string | 字段识别结果,以上各字段均包含此参数 |
++ location | 否 | object | 字段位置信息,当请求参数 location=true 时,以上各字段均包含此参数 |
+++ top | 否 | uint32 | 字段的上边距 |
+++ left | 否 | uint32 | 字段的左边距 |
+++ height | 否 | uint32 | 字段的高度 |
+++ width | 否 | uint32 | 字段的宽度 |
++ probability | 否 | object | 字段识别结果置信度,当请求参数 probability=true 时,以上各字段均包含此参数 |
+++ average | 否 | float | 字段识别结果中各字符的置信度平均值 |
+++ min | 否 | float | 字段识别结果中各字符的置信度最小值 |
+ CostDetail | 是 | array[] | 项目明细 |
CostDetail字段包含多个Array,每个数组包含多个object,见以下参数
字段 | 说明 |
---|---|
++ word_name | 字段名,包括:项目类型、项目名称、单价、数量、规格、金额 |
++ word | word_name字段对应的识别结果 |
返回示例
1{
2 "log_id": 1397090241579319296,
3 "words_result_num": 5,
4 "words_result": {
5 "PatientID": {
6 "word": "23683829"
7 },
8 "TotalAmount": {
9 "word": "600.00"
10 },
11 "Date": {
12 "word": "2020年11月04日"
13 },
14 "Name": {
15 "word": "范浩"
16 },
17 "CostDetail": [
18 [
19 {
20 "word_name": "清单项目名称",
21 "word": "普通过敏原(新)筛查"
22 },
23 {
24 "word_name": "单价",
25 "word": "580.00"
26 },
27 {
28 "word_name": "数量",
29 "word": "1.00"
30 },
31 {
32 "word_name": "金额",
33 "word": "580.00"
34 },
35 {
36 "word_name": "规格",
37 "word": "次"
38 },
39 {
40 "word_name": "项目类型",
41 "word": "化验费"
42 }
43 ],
44 [
45 {
46 "word_name": "清单项目名称",
47 "word": "总IgE测定"
48 },
49 {
50 "word_name": "单价",
51 "word": "20.00"
52 },
53 {
54 "word_name": "数量",
55 "word": "1.00"
56 },
57 {
58 "word_name": "金额",
59 "word": "20.00"
60 },
61 {
62 "word_name": "规格",
63 "word": "次"
64 },
65 {
66 "word_name": "项目类型",
67 "word": "化验费"
68 }
69 ]
70 ],
71 },
72}
办公文档识别
可对办公类文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景。
1public void docAnalysisOffice() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4 byte[] pdf_file =readFile("pdf路径") ;
5
6 // 调用办公文档识别
7 JSONObject fileResult = client.docAnalysisOffice(image, null);
8 JSONObject urlResult = client.docAnalysisOfficeUrl(url,null);
9 JSONObject pdfResult = client.docAnalysisOfficePdf(pdf_file, 1, null);
10 System.out.println("fileResult:"+fileResult);
11 System.out.println("urlResult:"+urlResult);
12 System.out.println("pdfResult:"+pdfResult);
13
14 // 如果有可选参数
15 HashMap<String, Object> option = new HashMap<>();
16 option.put("result_type", "small");
17 JSONObject fileResultOption = client.docAnalysisOffice(image, option);
18 JSONObject urlResultOption = client.docAnalysisOfficeUrl(url, option);
19 JSONObject pdfResultOption = client.docAnalysisOfficePdf(pdf_file, 1, option);
20 System.out.println("urlResultOption:"+urlResultOption);
21 System.out.println("fileResultOption:"+fileResultOption);
22 System.out.println("pdfResultOption:"+pdfResultOption);
23 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和 url/pdf_file 三选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 优先级:image > url > pdf_file,当image字段存在时,url、pdf_file字段失效 |
url | 和 image/pdf_file 三选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式优先级:image > url > pdf_file,当image字段存在时,url字段失效请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | - | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | - | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
language_type | 否 | string | CHN_ENG/ ENG | 识别语言类型,默认为CHN_ENG 可选值包括: =CHN_ENG:中英文 =ENG:英文 |
result_type | 否 | string | big/small | 返回识别结果是按单行结果返回,还是按单字结果返回,默认为big。 =big:返回行识别结果 =small:返回行识别结果之上还会返回单字结果 |
detect_direction | 否 | string | true/false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。其中, 0 :正向 1:逆时针旋转90度 2:逆时针旋转180度 3:逆时针旋转270度 |
line_probability | 否 | string | true/false | 是否返回每行识别结果的置信度。默认为false |
disp_line_poly | 否 | string | true/false | 是否返回每行的四角点坐标。默认为false |
words_type | 否 | string | handwring_only/ handprint_mix | 文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别 |
layout_analysis | 否 | string | true/false | 是否分析文档版面:包括layout(图、表、标题、段落、目录);attribute(栏、页眉、页脚、页码、脚注)的分析输出 |
erase_seal | 否 | string | true/false | 是否先擦除水印、印章后再识别文档 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
img_direction | 否 | int32 | detect_direction=true 时返回该字段。检测到的图像朝向,0 :正向; 1:逆时针旋转90度;2:逆时针旋转180度;3:逆时针旋转270度 |
results_num | 是 | uint32 | 识别结果数,表示results的元素个数 |
results | 是 | array[] | 识别结果数组 |
+ words_type | 是 | string | 文字属性(手写、印刷),handwriting 手写,print 印刷 |
+ words | 是 | array[] | 整行的识别结果数组 |
++ line_probability | 否 | array[] | line_probability=true时返回。识别结果中每一行的置信度值,包含average:行置信度平均值,min:行置信度最小值 |
+++ average | 否 | float | 行置信度 |
+++ min | 否 | float | 整行中单字的最低置信度 |
++ word | 是 | float | 整行的识别结果 |
++ poly_location | 否 | array[] | 是否返回每行的四角点坐标,disp_line_poly=true时返回 |
++ words_location | 是 | array[] | 整行的矩形框坐标。位置数组(坐标0点为左上角) |
+++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 是 | uint32 | 表示定位定位位置的长方形的宽度 |
+++ height | 是 | uint32 | 表示位置的长方形的高度 |
+ chars | 否 | array[] | result_type=small时返回。单字符结果数组 |
++ char | 否 | string | result_type=small时返回。每个单字的内容 |
++ chars_location | 否 | array[] | 每个单字的矩形框坐标。位置数组(坐标0点为左上角) |
+++ left | 否 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 否 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 否 | uint32 | 表示定位定位位置的长方形的宽度 |
+++ height | 否 | uint32 | 表示位置的长方形的高度 |
layouts_num | 否 | uint32 | 版面分析结果数,表示layout的元素个数 |
layouts | 否 | array[] | 每个「栏:section」里面的文档版面模块数组,包含表格、图、段落文本、标题、目录等5个模块;每个模块的坐标位置;段落文本和表格内文本内容对应的行序号id。 |
+ layout | 否 | string | 版面分析的标签结果。表格:table, 图:figure, 文本:text, 标题:title ,目录:contents |
+ layout_location | 否 | array[] | 文档版面信息标签的位置,四个顶点: 左上,右上,右下,左下 |
++ x | 否 | uint32 | 水平坐标(坐标0点为左上角) |
++ y | 否 | uint32 | 水平坐标(坐标0点为左上角) |
+ layout_idx | 否 | array[] | 文档版面信息中的文本在results结果中的位置:版面文本标签对应的行序号ID为n,则此标签中的文本在results结果中第n+1条展示) |
pdf_file_size | 否 | string | 传入PDF文件的总页数,当 pdf_file 参数有效时返回该字段 |
sec_rows | 否 | uint32 | 将所有的版面中的「栏:section」内容表示成 M x N 的网格,sec_rows = M |
sec_cols | 否 | uint32 | 将所有的版面中的「分栏」内容表示成 M x N 的网格,sec_cols = N |
sections | 否 | array[] | 一张图片中包含的5大版面属性,包含:栏,页眉,页脚,页码,脚注,该数组里有属性的标签、属性的位置、属性所包含文本内容的id序号。 其中,栏(section)里面包含5个模块内容,有:表格、图、段落文本、标题、目录(在返回参数layouts里输出)。 |
+ attribute | 否 | string | 版面分析的属性标签结果,栏:section, 页眉:header, 页脚:footer, 页码:number,脚注:footnote。 |
+ attri_location | 否 | array[] | 版面分析的属性所在位置,四个顶点: 左上,右上,右下,左下 |
++ x | 否 | uint32 | 水平坐标(坐标0点为左上角) |
++ y | 否 | uint32 | 水平坐标(坐标0点为左上角) |
+ sec_idx | 否 | string | sections返回参数中的5个版面属性里,包含的内容序号标识 |
++ idx | 否 | string | sections返回参数中的5个版面属性里,每个属性下包含的文本行id序号 |
++ para_idx | 否 | string | 当且仅当attribute=section时才会返回。表示,返回参数中的「栏:section」里面,所包含的表格、图、段落文本、标题、目录等5个模块返回的顺序号id(即layouts返回结果中,每个模块的返回顺序号) |
++ row_idx | 否 | string | 当且仅当attribute=section时才会返回。表示,将所有栏表示成 M xN 的网格,所属网格的行的id。 |
++ col_idx | 否 | string | 当且仅当attribute=section时才会返回。表示,将所有栏表示成 M xN 的网格,所属网格的列的id。 |
返回示例
1{
2 "results_num": 5,
3 "log_id": "1410491260247950412",
4 "results": [
5 {
6 "words_type": "print",
7 "words": {
8 "words_location": {
9 "top": 88,
10 "left": 442,
11 "width": 142,
12 "height": 49
13 },
14 "word": "行程单"
15 }
16 },
17 {
18 "words_type": "print",
19 "words": {
20 "words_location": {
21 "top": 241,
22 "left": 439,
23 "width": 393,
24 "height": 37
25 },
26 "word": "美国东海岸名校8天7晚"
27 }
28 },
29 {
30 "words_type": "print",
31 "words": {
32 "words_location": {
33 "top": 318,
34 "left": 436,
35 "width": 774,
36 "height": 31
37 },
38 "word": "国会大厦位于华盛顿25米高的国会山上,是美国的心脏建筑。"
39 }
40 },
41 {
42 "words_type": "print",
43 "words": {
44 "words_location": {
45 "top": 374,
46 "left": 434,
47 "width": 805,
48 "height": 31
49 },
50 "word": "中央顶楼上的大圆顶上立有一尊6米高的自由女神青铜雕像。"
51 }
52 },
53 {
54 "words_type": "print",
55 "words": {
56 "words_location": {
57 "top": 431,
58 "left": 436,
59 "width": 556,
60 "height": 31
61 },
62 "word": "东面的大草坪是历届总统举行就职典礼的地方。"
63 }
64 }
65 ]
66}
印章识别
检测并识别合同文件或常用票据中的印章,输出文字内容、印章位置信息以及相关置信度,已支持圆形章、椭圆形章、方形章等常见印章检测与识别。
1 public void seal() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4 byte[] pdf_file =readFile("pdf路径") ;
5
6 // 调用印章识别
7 JSONObject fileResult = client.seal(image);
8 JSONObject urlResult = client.sealUrl(url);
9 JSONObject pdfResult = client.sealPdf(pdf_file, 1);
10 System.out.println("fileResult:"+fileResult);
11 System.out.println("urlResult:"+urlResult);
12 System.out.println("pdfResult:"+pdfResult);
13 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和 url/pdf_file 三选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 优先级:image > url > pdf_file,当image字段存在时,url、pdf_file字段失效 |
url | 和 image/pdf_file 三选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式优先级:image > url > pdf_file,当image字段存在时,url字段失效请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | - | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | - | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
result_num | 是 | uint32 | 识别结果数,表示results的元素个数 |
result | 是 | array[] | 定位结果数组 |
+ location | 是 | object | 位置数组(坐标0点为左上角) |
++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
+ probability | 是 | float | 每一个识别结果的置信度值 |
+ type | 是 | string | 印章的类别,共有circle(圆章),ellipse(椭圆章),rectangle(方章)三种 |
+ major | 是 | object | 主字段内容 |
++ words | 是 | string | 主字段识别内容,即章内上环弯曲文字结果 |
++ probability | 是 | float | 主字段识别内容的置信度 |
+ minor | 是 | array[] | 其他字段内容,即除主字段外的文字识别内容均放置于该参数中返回,若章内不存在其他字段文字,则该参数为空 |
++ words | 是 | string | 其他字段识别内容 |
++ probability | 是 | float | 其他字段识别内容的置信度 |
pdf_file_size | 否 | string | 传入PDF文件的总页数,当 pdf_file 参数有效时返回该字段 |
返回示例
1{
2 "result": [
3 {
4 "major": {
5 "probability": 0.99759155511856,
6 "words": "峨眉山旅游股份有限公司成都峨眉山雪芽大酒店分公司"
7 },
8 "minor": [
9 {
10 "probability": 0.99994027614594,
11 "words": "前厅部"
12 }
13 ],
14 "probability": 0.9936261177063,
15 "location": {
16 "top": 594,
17 "left": 918,
18 "width": 150,
19 "height": 142
20 },
21 "type": "circle"
22 }
23 ],
24 "log_id": "1349006147834609664",
25 "result_num": 1
26}
身份证混贴识别
身份证混贴识别支持自动检测与识别身份证正反面在同一张图片上的场景,一次识别图片中身份证正反面所有字段。
支持对二代居民身份证正反面所有8个字段进行结构化识别,包括姓名、性别、民族、出生日期、住址、身份证号、签发机关、有效期限,识别准确率超过99%;同时支持身份证正面头像检测,并返回头像切片的base64编码及位置信息。
同时,支持对用户上传的身份证图片进行图像风险和质量检测,可识别图片是否为复印件或临时身份证,是否被翻拍或编辑,是否存在正反颠倒、模糊、欠曝、过曝等质量问题。
1public void multiIdcard() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4
5 // 调用身份证混贴识别
6 JSONObject fileResult = client.multiIdcard(image, null);
7 JSONObject urlResult = client.multiIdcardUrl(url, null);
8 System.out.println("fileResult:"+fileResult);
9 System.out.println("urlResult:"+urlResult);
10
11 // 如果有可选参数
12 HashMap<String, Object> option = new HashMap<>();
13 option.put("detect_risk", "true");
14 JSONObject fileResultOption = client.multiIdcard(image, option);
15 JSONObject urlResultOption = client.multiIdcardUrl(url, option);
16 System.out.println("fileResultOption:"+fileResultOption);
17 System.out.println("urlResultOption:"+urlResultOption);
18 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
detect_risk | 否 | string | true/false | 是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。- true:开启,请查看返回参数risk_type;- false:不开启 |
detect_quality | 否 | string | true/false | 是否开启身份证质量类型(边框/四角不完整、头像或关键字段被遮挡/马赛克)检测功能,默认不开启,即:false。- true:开启,请查看返回参数card_quality;- false:不开启 |
detect_photo | 否 | string | true/false | 是否检测头像内容,默认不检测。可选值:true-检测头像并返回头像的 base64 编码及位置信息 |
detect_card | 否 | string | true/false | 是否检测身份证进行裁剪,默认不检测。可选值:true-检测身份证并返回证照的 base64 编码及位置信息 |
返回参数详情 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result | 是 | array[] | 定位和识别结果数组 |
+ card_info | 是 | object | 识别结果信息,包含身份证的位置信息、风险检测信息、质量检测信息、正反面信息、方向信息 |
++ card_location | 是 | object | 身份证的位置信息(坐标0点为左上角) |
++ card_type | 是 | string | - idcard_front:身份证正面(头像面) - idcard_back:身份证反面(国徽面) |
direction | 是 | int32 | 图像方向。 - - 1:未定义, - 0:正向, - 1:逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
++ image_status | 是 | string | normal-识别正常 reversed_side-身份证正反面颠倒 non_idcard-上传的图片中不包含身份证 blurred-身份证模糊 other_type_card-其他类型证照 over_exposure-身份证关键字段反光或过曝 over_dark-身份证欠曝(亮度过低) unknown-未知状态 |
++ risk_type | 否 | string | 输入参数 detect_risk = true 时,则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknown-其他未知情况 |
++ edit_tool | 否 | string | 如果参数 detect_risk = true 时,则返回此字段。如果检测身份证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值无此参数 |
card_quality | 否 | object | 输入参数 detect_quality = true 时,则返回该字段识别身份证质量类型: IsClear - 是否清晰; IsComplete - 是否边框/四角完整; IsNoCover - 是否头像、关键字段无遮挡/马赛克。 及对应的概率:IsComplete_propobility、IsNoCover_propobility、IsClear_propobility,值在0-1之间,值越大表示图像质量越好。 默认阈值:当 IsComplete_propobility 超过0.5时,IsComplete返回1,低于0.5,则返回0。IsNoCover_propobility、IsClear_propobility 同上 |
++ photo | 否 | string | 当请求参数 detect_photo = true时返回,头像切图的 base64 编码(无编码头,需自行处理) |
++ photo_location | 否 | array[] | 当请求参数 detect_photo = true时返回,头像的位置信息(坐标0点为左上角) |
++ card_image | 否 | string | 当请求参数 detect_card = true时返回,身份证裁剪切图的 base64 编码(无编码头,需自行处理) |
++ idcard_number_type | 是 | string | 用于校验身份证号码、性别、出生是否一致,输出结果及其对应关系如下: - 1: 身份证正面所有字段全为空 0: 身份证证号不合法,此情况下不返回身份证证号 1: 身份证证号和性别、出生信息一致 2: 身份证证号和性别、出生信息都不一致 3: 身份证证号和出生信息不一致 4: 身份证证号和性别信息不一致 |
+ card_result | 是 | object | 识别结果 |
++ words | 否 | string | 识别结果字符串 |
++ location | 否 | object | 位置数组(坐标0点为左上角) |
+++ left | 否 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 否 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 否 | uint32 | 表示定位位置的长方形的宽度 |
+++ height | 否 | uint32 | 表示定位位置的长方形的高度 |
返回示例
1{
2 "words_result": [
3 {
4 "card_info": {
5 "card_location": {
6 "top": 121,
7 "left": 687,
8 "width": 501,
9 "height": 323
10 },
11 "risk_type": "normal",
12 "idcard_number_type": 1,
13 "edit_tool": "",
14 "image_status": "normal",
15 "card_type": "idcard_front",
16 "direction": 0
17 },
18 "card_result": {
19 "姓名": {
20 "words": "王媛",
21 "location": {
22 "top": 158,
23 "left": 788,
24 "width": 67,
25 "height": 26
26 }
27 },
28 "民族": {
29 "words": "汉",
30 "location": {
31 "top": 204,
32 "left": 884,
33 "width": 19,
34 "height": 21
35 }
36 },
37 "住址": {
38 "words": "北京市海淀区西北旺东路10号院",
39 "location": {
40 "top": 282,
41 "left": 782,
42 "width": 205,
43 "height": 51
44 }
45 },
46 "公民身份号码": {
47 "words": "410433199510104518",
48 "location": {
49 "top": 385,
50 "left": 863,
51 "width": 266,
52 "height": 29
53 }
54 },
55 "出生": {
56 "words": "19951010",
57 "location": {
58 "top": 240,
59 "left": 784,
60 "width": 163,
61 "height": 25
62 }
63 },
64 "性别": {
65 "words": "女",
66 "location": {
67 "top": 202,
68 "left": 789,
69 "width": 19,
70 "height": 22
71 }
72 }
73 }
74 },
75 {
76 "card_info": {
77 "card_location": {
78 "top": 526,
79 "left": 66,
80 "width": 524,
81 "height": 323
82 },
83 "risk_type": "normal",
84 "edit_tool": "",
85 "image_status": "normal",
86 "card_type": "idcard_back",
87 "direction": 0
88 },
89 "card_result": {
90 "失效日期": {
91 "words": "20350413",
92 "location": {
93 "top": 801,
94 "left": 394,
95 "width": 95,
96 "height": 19
97 }
98 },
99 "签发机关": {
100 "words": "北京市公安局海淀分局",
101 "location": {
102 "top": 760,
103 "left": 290,
104 "width": 180,
105 "height": 19
106 }
107 },
108 "签发日期": {
109 "words": "20150413",
110 "location": {
111 "top": 801,
112 "left": 289,
113 "width": 89,
114 "height": 19
115 }
116 }
117 }
118 }
119 ],
120 "direction": 0,
121 "log_id": 1397109704106180608
122}
车辆证照混贴识别
车辆证照混贴识别接口支持自动检测与识别行驶证、驾驶证混贴图片,即识别机动车行驶证主页及副页、机动车驾驶证主页及副页在同一张图片上的场景,一次性识别图片中多个行驶证、驾驶证的所有字段。
支持对机动车行驶证主页及副页所有22个字段进行结构化识别,包括号牌号码、车辆类型、所有人、品牌型号、车辆识别代码、发动机号码、核定载人数、质量、尺寸、检验记录等;支持对机动车驾驶证正页及副页所有15个字段进行结构化识别,包括证号、姓名、性别、国籍、住址、出生日期、初次领证日期、准驾车型、有效期限、发证单位、档案编号等。
1 public void mixedMultiVehicle() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4
5 // 调用车辆证照混贴识别
6 JSONObject fileResult = client.mixedMultiVehicle(image, null);
7 JSONObject urlResult = client.mixedMultiVehicleUrl(url, null);
8 System.out.println("fileResult:"+fileResult);
9 System.out.println("urlResult:"+urlResult);
10
11 // 如果有可选参数
12 HashMap<String, Object> option = new HashMap<>();
13 option.put("unified", "true");
14 JSONObject fileResultOption = client.mixedMultiVehicle(image, option);
15 JSONObject urlResultOption = client.mixedMultiVehicleUrl(url, option);
16 System.out.println("fileResultOption:"+fileResultOption);
17 System.out.println("urlResultOption:"+urlResultOption);
18 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
detect_direction | 否 | string | true/false | - false:默认值不进行图像方向自动矫正 - true: 开启图像方向自动矫正功能,可对旋转 90/180/270 度的图片进行自动矫正并识别 |
unified | 否 | string | true/false | - false:默认值,不进行归一化处理- true:对输出字段进行归一化处理,将新/老版行驶证的“注册登记日期/注册日期”统一为”注册日期“进行输出 |
返回参数详情 |
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object | 识别结果 |
card_type | 是 | string | 证件类型,vehicle_front、vehicle_back、driving_front和driving_back,分别对应行驶证正、副页,驾驶证正、副页 |
direction | 否 | int32 | 图像方向,当图像旋转时,返回该参数。- - 1:未定义,- 0:正向,- 1:逆时针90度,- 2:逆时针180度,- 3:逆时针270度 |
probability | 是 | uint32 | 检测到证件的置信度 |
location | 是 | object | 证件位置数组(坐标0点为左上角) |
+ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
+ height | 是 | uint32 | 表示定位位置的长方形的高度 |
license_info | 是 | object | 识别结果信息,包含图片中多个行驶证、驾驶证的识别结果 |
+ word_name | 是 | string | 字段名,如果license_info对应行驶证,字段名包含号牌号码、车辆类型、所有人、品牌型号、车辆识别代码、发动机号码、核定载人数、质量、尺寸、检验记录等;如果license_info对应驾驶证,字段名包含证号、姓名、性别、国籍、住址、出生日期、初次领证日期、准驾车型、有效期限、发证单位、档案编号等 |
+ word | 是 | string | word_name字段对应的识别结果 |
返回示例
1{
2 "words_result":[
3 {
4 "license_info":[
5 {
6 "word_name":"证号",
7 "word":"320621196512031267"
8 },
9 {
10 "word_name":"姓名",
11 "word":"程成"
12 },
13 {
14 "word_name":"性别",
15 "word":"男"
16 },
17 {
18 "word_name":"国籍",
19 "word":"中国"
20 },
21 {
22 "word_name":"住址",
23 "word":"江苏省南通市"
24 },
25 {
26 "word_name":"出生日期",
27 "word":"19651203"
28 },
29 {
30 "word_name":"初次领证日期",
31 "word":"20110311"
32 },
33 {
34 "word_name":"准驾车型",
35 "word":"B2"
36 },
37 {
38 "word_name":"有效起始日期",
39 "word":"20170311"
40 },
41 {
42 "word_name":"失效日期",
43 "word":"20270311"
44 },
45 {
46 "word_name":"发证单位",
47 "word":"江苏省南通市公安局交通警察支队"
48 }
49 ],
50 "probability":0.99496907,
51 "location":{
52 "top":14,
53 "left":15,
54 "width":701,
55 "height":459
56 },
57 "card_type":"driving_front",
58 "direction":0
59 },
60 {
61 "license_info":[
62 {
63 "word_name":"证号",
64 "word":"320621196512031267"
65 },
66 {
67 "word_name":"姓名",
68 "word":"程成"
69 },
70 {
71 "word_name":"档案编号",
72 "word":"320601650706"
73 },
74 {
75 "word_name":"记录",
76 "word":"自2017年03月06日至有效起始日期有效。请于每个记分周期结束后三十日接受审验。无记分的,免予本次审验。"
77 }
78 ],
79 "probability":0.9815229177,
80 "location":{
81 "top":7,
82 "left":731,
83 "width":650,
84 "height":456
85 },
86 "card_type":"driving_back",
87 "direction":0
88 },
89 {
90 "license_info":[
91 {
92 "word_name":"号牌号码",
93 "word":"京A10D08"
94 },
95 {
96 "word_name":"车辆类型",
97 "word":"小型面包车"
98 },
99 {
100 "word_name":"所有人",
101 "word":"王京"
102 },
103 {
104 "word_name":"住址",
105 "word":"北京市石景山区"
106 },
107 {
108 "word_name":"使用性质",
109 "word":"非营运"
110 },
111 {
112 "word_name":"品牌型号",
113 "word":"东风牌EQ6456PF"
114 },
115 {
116 "word_name":"车辆识别代号",
117 "word":"LGK022K69A9240616"
118 },
119 {
120 "word_name":"发动机号码",
121 "word":"10066180"
122 },
123 {
124 "word_name":"注册日期",
125 "word":"20100707"
126 },
127 {
128 "word_name":"发证日期",
129 "word":"20191020"
130 },
131 {
132 "word_name":"发证单位",
133 "word":"北京市公安局交通警察支队"
134 }
135 ],
136 "probability":0.9907341003,
137 "location":{
138 "top":532,
139 "left":736,
140 "width":622,
141 "height":415
142 },
143 "card_type":"vehicle_front",
144 "direction":0
145 },
146 {
147 "license_info":[
148 {
149 "word_name":"号牌号码",
150 "word":"京A10D08"
151 },
152 {
153 "word_name":"备注",
154 "word":""
155 },
156 {
157 "word_name":"整备质量",
158 "word":"985kg"
159 },
160 {
161 "word_name":"核定载质量",
162 "word":""
163 },
164 {
165 "word_name":"外廓尺寸",
166 "word":"3660X1560X1925mm"
167 },
168 {
169 "word_name":"核定载人数",
170 "word":"7人"
171 },
172 {
173 "word_name":"总质量",
174 "word":"1565kg"
175 },
176 {
177 "word_name":"准牵引总质量",
178 "word":""
179 },
180 {
181 "word_name":"档案编号",
182 "word":""
183 },
184 {
185 "word_name":"检验记录",
186 "word":"2020年07月京A(03)"
187 },
188 {
189 "word_name":"燃油类型",
190 "word":"汽油"
191 }
192 ],
193 "probability":0.9925737381,
194 "location":{
195 "top":554,
196 "left":12,
197 "width":609,
198 "height":416
199 },
200 "card_type":"vehicle_back",
201 "direction":0
202 }
203 ],
204 "log_id":1420339917916065252,
205 "words_result_num":4
206}
机动车登记证书识别
支持对机动车登记证书的15个关键字段进行结构化识别,包括编号、机动车所有人、登记机关、登记日期、登记编号、车辆类型等,同时支持检测发证机关章。
1 public void vehicleRegistrationCertificate() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4
5 // 调用机动车登记证书识别
6 JSONObject fileResult = client.vehicleRegistrationCertificate(image);
7 JSONObject urlResult = client.vehicleRegistrationCertificateUrl(url);
8 System.out.println("fileResult:"+fileResult);
9 System.out.println("urlResult:"+urlResult);
10 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
direction | 是 | int32 | 图像方向- 1:未定义,0:正向,1:逆时针90度,2:逆时针180度,3:逆时针270度 |
words_result | 是 | object | 识别结果数组 |
+ number | 是 | object | 编号 |
+ name_idcard_no | 是 | object | 机动车所有人/身份证明名称/号码 |
+ registration_authority | 是 | object | 登记机关 |
+ registration_date | 是 | object | 登记日期 |
+ registration_num | 是 | object | 机动车登记编号 |
+ vehicle_model | 是 | object | 车辆型号 |
+ vehicle_type | 是 | object | 车辆类型 |
+ vin | 是 | object | 车架号 |
+ engine_num | 是 | object | 发动机号 |
+ seating_capacity | 是 | object | 核定载客 |
+ body_color | 是 | object | 车身颜色 |
+ nature_of_use | 是 | object | 使用性质 |
+ date_of_production | 是 | object | 出厂日期 |
+ date_of_issue | 是 | object | 发证日期 |
+ seal_of_issue_authority | 是 | object | 发证机关章,1表示有,0表示无 |
返回示例
1{
2 "words_result": {
3 "registration_authority": {
4 "words": "江苏省昆山市公安局交通巡逻警察大队"
5 },
6 "vehicle_model": {
7 "words": "DHW6691R8CEE"
8 },
9 "vehicle_type": {
10 "words": "小型普通客车"
11 },
12 "registration_num": {
13 "words": "苏A88FF2"
14 },
15 "engine_num": {
16 "words": "2005533"
17 },
18 "number": {
19 "words": "32004574998"
20 },
21 "body_color": {
22 "words": "白"
23 },
24 "registration_date": {
25 "words": "2016-06-06"
26 },
27 "date_of_production": {
28 "words": "2016-03-11"
29 },
30 "seating_capacity": {
31 "words": "7"
32 },
33 "date_of_issue": {
34 "words": "2016-06-06"
35 },
36 "nature_of_use": {
37 "words": "非营运"
38 },
39 "vin": {
40 "words": "LVHRR8836G5004527"
41 },
42 "seal_of_issue_authority": {
43 "words": "1"
44 },
45 "name_idcard_no": {
46 "words": "汽车服务有限公司/统一社会信用代码/91320583088874412F"
47 }
48 },
49 "log_id": 1392089398849306624,
50 "direction": "0"
51}
智能财务票据识别
支持财务场景中13种常见票据的分类及结构化识别,包括增值税发票、卷票、机打发票、定额发票、火车票、出租车票、网约车行程单、飞机行程单、汽车票、过路过桥费、船票、机动车/二手车销售发票。支持多张不同种类票据在同一张图片上的混贴场景,可返回每张票据的位置、种类及票面信息的结构化识别结果。
1 public void multipleInvoice() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4 byte[] pdf_file =readFile("pdf路径") ;
5
6 // 调用智能财务票据识别
7 JSONObject fileResult = client.multipleInvoice(image null);
8 JSONObject urlResult = client.multipleInvoiceUrl(url, null);
9 JSONObject pdfResult = client.multipleInvoicePdf(pdf_file, 1, null);
10 System.out.println("fileResult:"+fileResult);
11 System.out.println("urlResult:"+urlResult);
12 System.out.println("pdfResult:"+pdfResult);
13
14 // 如果有可选参数
15 HashMap<String, Object> option = new HashMap<>();
16 option.put("verify_parameter", "true");
17 JSONObject fileResultOption = client.multipleInvoice(image, option);
18 JSONObject urlResultOption = client.multipleInvoiceUrl(url, option);
19 JSONObject pdfResultOption = client.multipleInvoicePdf(pdf_file, 1, option);
20 System.out.println("fileResultOption:"+fileResultOption);
21 System.out.println("urlResultOption:"+urlResultOption);
22 System.out.println("pdfResultOption:"+pdfResultOption);
23 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和 url/pdf_file 三选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 优先级:image > url > pdf_file,当image字段存在时,url、pdf_file字段失效 |
url | 和 image/pdf_file 三选一 | string | - | 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式优先级:image > url > pdf_file,当image字段存在时,url字段失效请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | - | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px优先级:image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | - | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容,若不传入,则默认识别第 1 页 |
verify_parameter | 否 | string | true/false | 是否开启验真,默认为 false,即不开启,当为 true 时,返回匹配发票验真接口所需的6要素信息,具体返回信息详见末尾说明 |
probability | 否 | string | true/false | 是否返回字段置信度,默认为 false ,即不返回 |
location | 否 | string | true/false | 是否返回字段位置坐标,默认为 false,即不返回 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
pdf_file_size | 否 | string | 传入PDF文件的总页数,当 pdf_file 参数有效时返回该字段 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
+ probability | 是 | string | 表示单张票据分类的置信度 |
+ left | 是 | string | 表示单张票据定位位置的长方形左上顶点的水平坐标 |
+ top | 是 | string | 表示单张票据定位位置的长方形左上顶点的垂直坐标 |
+ width | 是 | string | 表示单张票据定位位置的长方形的宽度 |
+ height | 是 | string | 表示单张票据定位位置的长方形的高度 |
+ type | 是 | string | 每一张票据的种类 |
+ result | 是 | array[] | 单张票据的识别结果数组 |
type 字段会返回以下17种结果,每种结果对应的票据类型详见下表 |
type 返回结果 | 说明 |
---|---|
vat_invoice | 增值税发票 |
taxi_receipt | 出租车票 |
train_ticket | 火车票 |
quota_invoice | 定额发票 |
air_ticket | 机票行程单 |
roll_normal_invoice | 卷票 |
printed_invoice | 机打发票 |
bus_ticket | 汽车票 |
toll_invoice | 过路过桥费发票 |
ferry_ticket | 船票 |
motor_vehicle_invoice | 机动车销售发票 |
used_vehicle_invoice | 二手车发票 |
taxi_online_ticket | 网约车行程单 |
limit_invoice | 限额发票 |
shopping_receipt | 购物小票 |
pos_invoice | POS小票 |
others | 其他 |
type 的返回结果为 vat_invoice,即“增值税发票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceTypeOrg | 是 | array[] | 发票名称 |
++ InvoiceType | 是 | array[] | 增值税发票的细分类型。不同细分类型的增值税发票发票输出:普通发票、专用发票、电子普通发票、电子专用发票、通行费电子普票、区块链发票、通用机打电子发票 |
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ InvoiceCodeConfirm | 是 | array[] | 发票代码的辅助校验码,一般业务情景可忽略 |
++ InvoiceNumConfirm | 是 | array[] | 发票号码的辅助校验码,一般业务情景可忽略 |
++ CheckCode | 是 | array[] | 校验码。增值税专票无此参数 |
++ InvoiceDate | 是 | array[] | 开票日期 |
++ PurchaserName | 是 | array[] | 购方名称 |
++ PurchaserRegisterNum | 是 | array[] | 购方纳税人识别号 |
++ PurchaserAddress | 是 | array[] | 购方地址及电话 |
++ PurchaserBank | 是 | array[] | 购方开户行及账号 |
++ Password | 是 | array[] | 密码区 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
++ SheetNum | 是 | array[] | 联次信息。专票第一联到第三联分别输出:第一联:记账联、第二联:抵扣联、第三联:发票联;普通发票第一联到第二联分别输出:第一联:记账联、第二联:发票联 |
++ Agent | 是 | array[] | 是否代开 |
++ OnlinePay | 是 | String | 电子支付标识。仅区块链发票含有此参数 |
++ SellerName | 是 | array[] | 销售方名称 |
++ SellerRegisterNum | 是 | array[] | 销售方纳税人识别号 |
++ SellerAddress | 是 | array[] | 销售方地址及电话 |
++ SellerBank | 是 | array[] | 销售方开户行及账号 |
++ TotalAmount | 是 | array[] | 合计金额 |
++ TotalTax | 是 | array[] | 合计税额 |
++ AmountInWords | 是 | array[] | 价税合计(大写) |
++ AmountInFiguers | 是 | array[] | 价税合计(小写) |
++ Payee | 是 | array[] | 收款人 |
++ Checker | 是 | array[] | 复核 |
++ NoteDrawer | 是 | array[] | 开票人 |
++ Remarks | 是 | array[] | 备注 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
++ CommodityName | 是 | array[] | 货物名称 |
++ CommodityType | 是 | array[] | 规格型号 |
++ CommodityUnit | 是 | array[] | 单位 |
++ CommodityNum | 是 | array[] | 数量 |
++ CommodityPrice | 是 | array[] | 单价 |
++ CommodityAmount | 是 | array[] | 金额 |
++ CommodityTaxRate | 是 | array[] | 税率 |
++ CommodityTax | 是 | array[] | 税额 |
++ CommodityPlateNum | 是 | array[] | 车牌号。仅通行费增值税电子普通发票含有此参数 |
++ CommodityVehicleType | 是 | array[] | 类型。仅通行费增值税电子普通发票含有此参数 |
++ CommodityStartDate | 是 | array[] | 通行日期起。仅通行费增值税电子普通发票含有此参数 |
++ CommodityEndDate | 是 | array[] | 通行日期止。仅通行费增值税电子普通发票含有此参数 |
+++ row | 是 | uint32 | 行号,以上各字段均包含 |
+++ word | 是 | string | 内容,以上各字段均包含 |
type 的返回结果为 taxi_receipt,即“出租车票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceCode | 是 | array[] | 发票代号 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ TaxiNum | 是 | array[] | 车牌号 |
++ Date | 是 | array[] | 日期 |
++ Time | 是 | array[] | 上下车时间 |
++ PickupTime | 是 | array[] | 上车时间 |
++ DropoffTime | 是 | array[] | 下车时间 |
++ Fare | 是 | array[] | 金额 |
++ FuelOilSurcharge | 是 | array[] | 燃油附加费 |
++ CallServiceSurcharge | 是 | array[] | 叫车服务费 |
++ TotalFare | 是 | array[] | 总金额 |
++ Location | 是 | array[] | 开票城市 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
++ PricePerkm | 是 | array[] | 单价 |
++ Distance | 是 | array[] | 里程 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 train_ticket,即“火车票”时,识别结果的返回字段如下 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ ticket_num | 是 | array[] | 车票号 |
++ starting_station | 是 | array[] | 始发站 |
++ train_num | 是 | array[] | 车次号 |
++ destination_station | 是 | array[] | 到达站 |
++ date | 是 | array[] | 出发日期 |
++ ticket_rates | 是 | array[] | 车票金额 |
++ seat_category | 是 | array[] | 席别 |
++ name | 是 | array[] | 乘客姓名 |
++ ID_card | 是 | array[] | 身份证号 |
++ serial_number | 是 | array[] | 序列号 |
++ sales_station | 是 | array[] | 售站 |
++ time | 是 | array[] | 时间 |
++ seat_num | 是 | array[] | 座位号 |
++ Waiting_area | 是 | array[] | 候检区 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 quota_invoice,即“定额发票”时,识别结果的返回字段如下 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ invoice_code | 是 | array[] | 发票代码 |
++ invoice_number | 是 | array[] | 发票号码 |
++ invoice_rate | 是 | array[] | 金额 |
++ invoice_rate_in_figure | 是 | array[] | 金额小写 |
++ invoice_rate_in_word | 是 | array[] | 金额大写 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
++ Location | 是 | array[] | 发票所在地 |
++ invoice_type | 是 | array[] | 发票名称 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 air_ticket,即“飞机行程单”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ name | 是 | array[] | 姓名 |
++ starting_station | 是 | array[] | 始发站 |
++ destination_station | 是 | array[] | 目的站 |
++ flight | 是 | array[] | 航班号 |
++ date | 是 | array[] | 日期 |
++ ticket_number | 是 | array[] | 电子客票号码 |
++ fare | 是 | array[] | 票价 |
++ dev_fund | 是 | array[] | 民航发展基金/基建费 |
++ oil_money | 是 | array[] | 燃油附加费 |
++ other_tax | 是 | array[] | 其他税费 |
++ ticket_rates | 是 | array[] | 合计金额 |
++ start_date | 是 | array[] | 填开日期 |
++ id_no | 是 | array[] | 身份证号 |
++ carrier | 是 | array[] | 承运人 |
++ time | 是 | array[] | 时间 |
++ issued_by | 是 | array[] | 订票渠道 |
++ serial_number | 是 | array[] | 印刷序号 |
++ insurance | 是 | array[] | 保险费 |
++ fare_basis | 是 | array[] | 客票级别 |
++ class | 是 | array[] | 座位等级 |
++ agent_code | 是 | array[] | 销售单位号 |
++ endorsement | 是 | array[] | 签注 |
++ allow | 是 | array[] | 免费行李 |
++ ck | 是 | array[] | 验证码 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 roll_normal_invoice,即“卷票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceType | 是 | array[] | 发票名称 |
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ MachineNum | 是 | array[] | 机打号码。仅增值税卷票含有此参数 |
++ MachineCode | 是 | array[] | 机器编号。仅增值税卷票含有此参数 |
++ InvoiceDate | 是 | array[] | 开票日期 |
++ PurchaserName | 是 | array[] | 购方名称 |
++ PurchaserRegisterNum | 是 | array[] | 购方纳税人识别号 |
++ SellerName | 是 | array[] | 销售方名称 |
++ SellerRegisterNum | 是 | array[] | 销售方纳税人识别号 |
++ TotalTax | 是 | array[] | 价税合计 |
++ AmountInWords | 是 | array[] | 合计金额(大写) |
++ AmountInFiguers | 是 | array[] | 合计金额(小写) |
++ Payee | 是 | array[] | 收款人 |
++ CheckCode | 是 | array[] | 校验码。增值税专票无此参数 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
++ CommodityName | 是 | array[] | 货物名称 |
++ CommodityNum | 是 | array[] | 数量 |
++ CommodityPrice | 是 | array[] | 单价 |
++ CommodityAmount | 是 | array[] | 金额 |
+++ row | 是 | uint32 | 行号,以上各字段均包含 |
+++ word | 是 | string | 内容,以上各字段均包含 |
type 的返回结果为 printed_invoice,即“机打发票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceType | 是 | array[] | 发票类型 |
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ InvoiceDate | 是 | array[] | 开票日期 |
++ AmountInFiguers | 是 | array[] | 合计金额小写 |
++ AmountInWords | 是 | array[] | 合计金额大写 |
++ MachineNum | 是 | array[] | 机打号码 |
++ CheckCode | 是 | array[] | 校验码 |
++ SellerName | 是 | array[] | 销售方名称 |
++ SellerRegisterNum | 是 | array[] | 销售方纳税人识别号 |
++ PurchaserName | 是 | array[] | 购买方名称 |
++ PurchaserRegisterNum | 是 | array[] | 购买方纳税人识别号 |
++ TotalTax | 是 | array[] | 合计税额 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
++ Time | 是 | array[] | 时间 |
++ SheetNum | 是 | array[] | 联次 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
++ CommodityName | 是 | array[] | 商品名称 |
++ CommodityUnit | 是 | array[] | 商品单位 |
++ CommodityPrice | 是 | array[] | 商品单价 |
++ CommodityNum | 是 | array[] | 商品数量 |
++ CommodityAmount | 是 | array[] | 商品金额 |
+++ row | 是 | uint32 | 行号,以上各字段均包含 |
+++ word | 是 | string | 内容,以上各字段均包含 |
type 的返回结果为 bus_ticket,即“汽车票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ Date | 是 | array[] | 日期 |
++ Time | 是 | array[] | 时间 |
++ ExitStation | 是 | array[] | 出发站 |
++ Amount | 是 | array[] | 金额 |
++ IdCard | 是 | array[] | 身份证号 |
++ ArrivalStation | 是 | array[] | 到达站 |
++ Name | 是 | array[] | 姓名 |
++ InvoiceTime | 是 | array[] | 开票日期 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 toll_invoice,即“过路过桥费”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ Entrance | 是 | array[] | 入口 |
++ Exit | 是 | array[] | 出口 |
++ OutDate | 是 | array[] | 日期 |
++ OutTime | 是 | array[] | 时间 |
++ TotalAmount | 是 | array[] | 金额 |
++ Province | 是 | array[] | 省 |
++ City | 是 | array[] | 市 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 ferry_ticket,即“船票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ InvoiceType | 是 | array[] | 发票类型 |
++ InvoiceCode | 是 | array[] | 发票代码 |
++ InvoiceNum | 是 | array[] | 发票号码 |
++ ExitStation | 是 | array[] | 出发地点 |
++ ArrivalStation | 是 | array[] | 到达地点 |
++ Amount | 是 | array[] | 总金额 |
++ Date | 是 | array[] | 开票日期 |
++ MoneyType | 是 | array[] | 金额类型 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 motor_vehicle_invoice,即“机动车销售发票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ date | 是 | array[] | 开票日期 |
++ fapiao-daima | 是 | array[] | 发票代码/机打代码 |
++ fapiao-haoma | 是 | array[] | 发票号码/机打号码 |
++ printed-daima | 是 | array[] | 机打代码 |
++ printed-haoma | 是 | array[] | 机打号码 |
++ machine-num | 是 | array[] | 机器编号 |
++ buyer-name | 是 | array[] | 购买方名称 |
++ payer-tax-num | 是 | array[] | 购买方身份证号码/组织机构代码 |
++ car-class | 是 | array[] | 车辆类型 |
++ car-model | 是 | array[] | 厂牌型号 |
++ product-location | 是 | array[] | 产地 |
++ certificate-num | 是 | array[] | 合格证号 |
++ engine-num | 是 | array[] | 发动机号码 |
++ vin-num | 是 | array[] | 车架号码 |
++ price-tax-big | 是 | array[] | 价税合计 |
++ price-tax-small | 是 | array[] | 价税合计小写 |
++ saler | 是 | array[] | 销货单位名称 |
++ saler-phone | 是 | array[] | 销货单位电话 |
++ saler-tax-num | 是 | array[] | 销货单位纳税人识别号 |
++ saler-bank-num | 是 | array[] | 销货单位账号 |
++ saler-address | 是 | array[] | 销货单位地址 |
++ saler-bank | 是 | array[] | 销货单位开户银行 |
++ tax-rate | 是 | array[] | 税率 |
++ tax | 是 | array[] | 税额 |
++ tax-jiguan | 是 | array[] | 主管税务机关 |
++ tax-jiguan-daima | 是 | array[] | 主管税务机关代码 |
++ price | 是 | array[] | 不含税价格 |
++ limit-mount | 是 | array[] | 限乘人数 |
++ toonage | 是 | array[] | 吨位 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 used_vehicle_invoice,即“二手车销售发票”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ invoice_code | 是 | array[] | 发票代码 |
++ invoice_num | 是 | array[] | 发票号码 |
++ date | 是 | array[] | 开票日期 |
++ tax_code | 是 | array[] | 税控码 |
++ buyer | 是 | array[] | 买方 |
++ buyer_id | 是 | array[] | 买方身份证号 |
++ buyer_station | 是 | array[] | 买方地址 |
++ buyer_tel | 是 | array[] | 买方电话 |
++ saler | 是 | array[] | 卖方 |
++ saler_id | 是 | array[] | 卖方身份证号 |
++ saler_station | 是 | array[] | 卖方地址 |
++ saler_tel | 是 | array[] | 卖方电话 |
++ car_plate | 是 | array[] | 车牌号 |
++ car_certificate | 是 | array[] | 登记证号 |
++ car_class | 是 | array[] | 车辆类型 |
++ vin_num | 是 | array[] | 车架号 |
++ model | 是 | array[] | 厂牌型号 |
++ to_station | 是 | array[] | 转入地车管所名称 |
++ big_price | 是 | array[] | 车价合计大写 |
++ small_price | 是 | array[] | 车价合计小写 |
++ car_market | 是 | array[] | 二手车市场 |
++ tax_num | 是 | array[] | 纳税人识别号 |
++ tax_location | 是 | array[] | 纳税人地址 |
++ tax_tel | 是 | array[] | 纳税人电话 |
++ sheet_num | 是 | array[] | 联次 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
type 的返回结果为 taxi_online_ticket,即“网约车行程单”时,识别结果的返回字段如下
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ service_provider | 是 | array[] | 服务商 |
++ start_time | 是 | array[] | 行程开始时间 |
++ destination_time | 是 | array[] | 行程结束时间 |
++ phone | 是 | array[] | 行程人手机号 |
++ application_date | 是 | array[] | 申请日期 |
++ total_fare | 是 | array[] | 总金额 |
++ item_num | 是 | array[] | 行程信息中包含的行程数量 |
+++ word | 是 | string | 识别结果字符串,以上各字段均包含 |
++ items | 是 | array[] | 行程信息 |
++++ item_id | 是 | array[] | 行程信息的对应序号 |
++++ pickup_time | 是 | array[] | 上车时间 |
++++ pickup_date | 是 | array[] | 上车日期 |
++++ car_type | 是 | array[] | 车型 |
++++ distance | 是 | array[] | 里程 |
++++ start_place | 是 | array[] | 起点 |
++++ destination_place | 是 | array[] | 终点 |
++++ city | 是 | array[] | 城市 |
++++ fare | 是 | array[] | 金额 |
当验真参数开启(即 verify_parameter=true 时),返回匹配发票验真接口所需的6要素信息
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
++ invoice_code | 是 | array[] | 发票代码 |
++ invoice_num | 是 | array[] | 发票号码 |
++ invoice_date | 是 | array[] | 开票日期。返回格式为 YYYYMMDD,例:20210101 |
++ invoice_type | 是 | array[] | 发票种类。不同类型发票输出如下结果:增值税专用发票:special_vat_invoice增值税电子专票:elec_special_vat_invoice增值税普通发票:normal_invoice增值税普通发票(电子):elec_normal_invoice增值税普通发票(卷式):roll_normal_invoice通行费增值税电子普通发票:toll_elec_normal_invoice货运运输业增值税专用发票:special_freight_transport_invoice机动车销售发票:motor_vehicle_invoice二手车销售发票:used_vehicle_invoice区块链发票:blockchain_invoice通用机打电子发票:printed_elec_invoice |
++ total_amount | 是 | array[] | 不含税金额 |
++ check_code | 否 | array[] | 检验码。如需使用百度的增值税发票验真接口,需提取返回值的后6位后,再传入验真接口 |
返回示例
1{
2 "words_result": [
3 {
4 "type": "vat_invoice",
5 "width": 0,
6 "probability": 0.9980429411,
7 "height": 649,
8 "left": 154,
9 "top": 177,
10 "result": {
11 "AmountInWords": [
12 {
13 "word": "叁佰陆拾圆整"
14 }
15 ],
16 "InvoiceNumConfirm": [
17 {
18 "word": "07286261"
19 }
20 ],
21 "CommodityEndDate": [],
22 "CommodityVehicleType": [],
23 "CommodityStartDate": [],
24 "CommodityPrice": [
25 {
26 "row": "1",
27 "word": "339.62"
28 }
29 ],
30 "NoteDrawer": [
31 {
32 "word": "余佳燕"
33 }
34 ],
35 "SellerAddress": [],
36 "CommodityNum": [
37 {
38 "row": "1",
39 "word": "1"
40 }
41 ],
42 "SellerRegisterNum": [
43 {
44 "word": "91330106673959654P"
45 }
46 ],
47 "MachineCode": [],
48 "Remarks": [],
49 "SellerBank": [
50 {
51 "word": "招商银行杭州高新支行502905023610702"
52 }
53 ],
54 "CommodityTaxRate": [
55 {
56 "row": "1",
57 "word": "6%"
58 }
59 ],
60 "TotalTax": [
61 {
62 "word": "20.38"
63 }
64 ],
65 "InvoiceCodeConfirm": [
66 {
67 "word": "3321192130"
68 }
69 ],
70 "CheckCode": [],
71 "InvoiceCode": [
72 {
73 "word": "3321192130"
74 }
75 ],
76 "InvoiceDate": [
77 {
78 "word": "2019年08月28日"
79 }
80 ],
81 "PurchaserRegisterNum": [
82 {
83 "word": "91110911717743469K"
84 }
85 ],
86 "InvoiceTypeOrg": [
87 {
88 "word": "浙江增值税专用发票"
89 }
90 ],
91 "OnlinePay": [],
92 "Password": [
93 {
94 "word": "508>3909>1*>01/-46709-6/3+*7+8>/1*19+7-0**>+58290-6>647-+324865*9*1<*2191/7754/<0>2<838+//5-69--748*<251408<"
95 }
96 ],
97 "Agent": [
98 {
99 "word": "否"
100 }
101 ],
102 "AmountInFiguers": [
103 {
104 "word": "360.00"
105 }
106 ],
107 "PurchaserBank": [
108 {
109 "word": "招商银行北京分行大电路支行866180100210002"
110 }
111 ],
112 "Checker": [
113 {
114 "word": "柳余"
115 }
116 ],
117 "City": [],
118 "TotalAmount": [
119 {
120 "word": "339.62"
121 }
122 ],
123 "CommodityAmount": [
124 {
125 "row": "1",
126 "word": "339.62"
127 }
128 ],
129 "PurchaserName": [
130 {
131 "word": "百度在线网络技术(北京)有限公司"
132 }
133 ],
134 "CommodityType": [],
135 "Province": [
136 {
137 "word": "浙江"
138 }
139 ],
140 "InvoiceType": [
141 {
142 "word": "专用发票"
143 }
144 ],
145 "SheetNum": [
146 {
147 "word": "第二联:抵扣联"
148 }
149 ],
150 "PurchaserAddress": [],
151 "CommodityTax": [
152 {
153 "row": "1",
154 "word": "20.38"
155 }
156 ],
157 "CommodityPlateNum": [],
158 "CommodityUnit": [
159 {
160 "row": "1",
161 "word": "套"
162 }
163 ],
164 "Payee": [
165 {
166 "word": "佳机"
167 }
168 ],
169 "CommodityName": [
170 {
171 "row": "1",
172 "word": "*信息技术服务*软件服务费"
173 }
174 ],
175 "SellerName": [
176 {
177 "word": "阿里云计算有限公司"
178 }
179 ],
180 "InvoiceNum": [
181 {
182 "word": "07286261"
183 }
184 ]
185 }
186 },
187 {
188 "type": "taxi_receipt",
189 "width": 0,
190 "probability": 0.9858493805,
191 "height": 615,
192 "left": 1325,
193 "top": 200,
194 "result": {
195 "PickupTime": [
196 {
197 "word": "10:50"
198 }
199 ],
200 "DropoffTime": [
201 {
202 "word": "17:06"
203 }
204 ],
205 "Time": [
206 {
207 "word": "10:50-17:06"
208 }
209 ],
210 "City": [
211 {
212 "word": ""
213 }
214 ],
215 "FuelOilSurcharge": [
216 {
217 "word": "1.00"
218 }
219 ],
220 "Date": [
221 {
222 "word": "2019-03-20"
223 }
224 ],
225 "Province": [
226 {
227 "word": "陕西省"
228 }
229 ],
230 "CallServiceSurcharge": [
231 {
232 "word": "0.00"
233 }
234 ],
235 "Fare": [
236 {
237 "word": "21.10"
238 }
239 ],
240 "TotalFare": [
241 {
242 "word": "22.00"
243 }
244 ],
245 "TaxiNum": [
246 {
247 "word": "AQ6353"
248 }
249 ],
250 "PricePerkm": [
251 {
252 "word": "2.30"
253 }
254 ],
255 "InvoiceCode": [
256 {
257 "word": "161001881016"
258 }
259 ],
260 "Distance": [
261 {
262 "word": "6.0"
263 }
264 ],
265 "InvoiceNum": [
266 {
267 "word": "05070716"
268 }
269 ],
270 "Location": [
271 {
272 "word": "陕西省"
273 }
274 ]
275 }
276 }
277 ],
278 "words_result_num": 2,
279 "log_id": 1438382953545048984
280}
增值税发票验真
支持 12 种增值税发票的信息核验,包括增值税专票、电子专票、普票、电子普票、卷票、区块链发票(深圳地区)、全电发票(增值税专用发票)、全电发票(普通发票)、通行费增值税电子普通发票、货物运输业增值税专用发票、机动车销售发票、二手车销售发票等,支持返回票面的全部信息。同时可直接与同平台的发票识别能力对接,完成发票识别的同时进行自动化验真。
1 public void vatInvoiceVerification() {
2 // 调用增值税发票验真
3 String invoice_code = "011002000000";
4 String invoice_num = "93705563";
5 String invoice_date = "20210000";
6 String invoice_type = "elec_normal_invoice";
7 String check_code = "000000";
8 String total_amount = "00.00";
9 JSONObject result = client.vatInvoiceVerification(invoice_code, invoice_num, invoice_date,
10 invoice_type, check_code, total_amount);
11 System.out.println("result:"+result);
12 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
invoice_code | 是 | string | - | 发票代码。全电发票(专用发票)、全电发票(普通发票)此参数可为空,其他类型发票均不可为空 |
invoice_num | 是 | string | - | 发票号码 |
invoice_date | 是 | string | - | 开票日期。格式YYYYMMDD,例:20210101 |
invoice_type | 是 | string | 增值税专用发票:special_vat_invoice增值税电子专用发票:elec_special_vat_invoice增值税普通发票:normal_invoice增值税普通发票(电子):elec_normal_invoice增值税普通发票(卷式):roll_normal_invoice通行费增值税电子普通发票:toll_elec_normal_invoice 区块链电子发票(目前仅支持深圳地区):blockchain_invoice全电发票(专用发票):elec_invoice_special全电发票(普通发票):elec_invoice_normal货运运输业增值税专用发票:special_freight_transport_invoice机动车销售发票:motor_vehicle_invoice二手车销售发票:used_vehicle_invoice | 发票种类 |
check_code | 是 | string | - | 校验码。填写发票校验码后6位,增值税电子专票、普票、电子普票、卷票、区块链电子发票、通行费增值税电子普通发票此参数不可为空,其他类型发票可为空 |
total_amount | 是 | string | - | 发票金额。增值税专票、电子专票、货运专票、机动车销售发票填写不含税金额;二手车销售发票填写车价合计;全电发票(专用发票)、全电发票(普通发票)填写价税合计金额,其他类型发票可为空 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 是 | object{} | 识别结果 |
VerifyResult | 是 | string | 查验结果。查验成功返回“0001”,查验失败返回对应查验结果错误码,详见末尾表格 |
VerifyMessage | 是 | string | 查验结果信息。查验成功且发票为真返回“查验成功发票一致“,查验失败返回对应错误原因,详见末尾表格 |
VerifyFrequency | 是 | string | 查验次数。为历史查验次数 |
InvalidSign | 是 | string | 是否作废(冲红)。Y:已作废;H:已冲红;N:未作废 |
InvoiceType | 是 | string | 发票种类 |
InvoiceCode | 是 | string | 发票代码 |
InvoiceNum | 是 | string | 发票号码 |
CheckCode | 是 | string | 校验码 |
InvoiceDate | 是 | string | 开票日期 |
MachineCode | 是 | string | 机器编号 |
增值税专票、电子专票、普票、电子普通发票、卷票、通行费增值税电子普通发票、货物运输业增值税专用发票返回信息
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
+ PurchaserName | 是 | string | 购方名称 |
+ PurchaserRegisterNum | 是 | string | 购方纳税人识别号 |
+ PurchaserAddress | 是 | string | 购方地址及电话 |
+ PurchaserBank | 是 | string | 购方开户行及账号 |
+ CommodityName | 是 | array[] | 货物名称/项目名称 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityType | 是 | array[] | 规格型号 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityUnit | 是 | array[] | 单位 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityNum | 是 | array[] | 数量 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityPrice | 是 | array[] | 单价 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityAmount | 是 | array[] | 金额 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityTaxRate | 是 | array[] | 税率 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityTax | 是 | array[] | 税额 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ SellerName | 是 | string | 销售方名称 |
+ SellerRegisterNum | 是 | string | 销售方纳税人识别号 |
+ SellerAddress | 是 | string | 销售方地址及电话 |
+ SellerBank | 是 | string | 销售方开户行及账号 |
+ TotalAmount | 是 | string | 合计金额 |
+ TotalTax | 是 | string | 合计税额 |
+ AmountInFiguers | 是 | string | 价税合计(小写) |
+ TollSign | 是 | string | 通行费标志。Y-可抵扣通行费,N-不可抵扣通行费。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
+ ZeroTaxRateIndicator | 是 | string | 零税率标识。空:非零税率,1:税率栏位显示“免税”,2:税率栏位显示“不征税”,3:零税率。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
+ CommodityPlateNum | 是 | array[] | 车牌号。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityVehicleType | 是 | array[] | 类型。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityStartDate | 是 | array[] | 通行日期起。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ CommodityEndDate | 是 | array[] | 通行日期止。通行费增值税电子普通发票返回信息,其他类型发票可忽略 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ Carrier | 是 | string | 承运人名称。货运专票返回信息,其他类型发票可忽略 |
+ CarrierCode | 是 | string | 承运人识别号。货运专票返回信息,其他类型发票可忽略 |
+ Recipient | 是 | string | 受票方名称。货运专票返回信息,其他类型发票可忽略 |
+ RecipientCode | 是 | string | 受票方识别号。货运专票返回信息,其他类型发票可忽略 |
+ Receiver | 是 | string | 收货人名称。货运专票返回信息,其他类型发票可忽略 |
+ ReceiverCode | 是 | string | 收货人识别号。货运专票返回信息,其他类型发票可忽略 |
+ Sender | 是 | string | 发货人名称。货运专票返回信息,其他类型发票可忽略 |
+ SenderCode | 是 | string | 发货人识别号。货运专票返回信息,其他类型发票可忽略 |
+ TransportCargoInformation | 是 | string | 运输货物信息。货运专票返回信息,其他类型发票可忽略 |
+ DepartureViaArrival | 是 | string | 起运地、经由、到达地。货运专票返回信息,其他类型发票可忽略 |
+ TaxControlNum | 是 | string | 税控盘号。货运专票返回信息,其他类型发票可忽略 |
+ VehicleType | 是 | string | 车种车号。货运专票返回信息,其他类型发票可忽略 |
+ VehicleTonnage | 是 | string | 车船吨位。货运专票返回信息,其他类型发票可忽略 |
+ CommodityExpenseItem | 是 | array[] | 费用项目。货运专票返回信息,其他类型发票可忽略 |
++ row | 是 | uint32 | 行号 |
++ word | 是 | string | 内容 |
+ NoteDrawer | 是 | string | 开票人 |
+ Checker | 是 | string | 复核 |
+ Payee | 是 | string | 收款人 |
+ Remarks | 是 | string | 备注 |
+ ESVATURL | 是 | string | 增值税电子专票(即 ofd 发票)的下载地址 |
+ ListLabel | 是 | string | 清单标识,Y:带清单;N:无清单;说明:只有当发票种类为:增值税专票,电子专票,普票,电子普通发票时返回此字段的值 |
机动车销售发票返回信息
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
+ Purchaser | 是 | string | 购买方名称 |
+ PurchaserCode | 是 | string | 购买方身份证号/组织机构代码 |
+ VehicleType | 是 | string | 车辆类型 |
+ ManuModel | 是 | string | 厂牌型号 |
+ Origin | 是 | string | 产地 |
+ CertificateNum | 是 | string | 合格证号书 |
+ CommodityInspectionNum | 是 | string | 商检单号 |
+ EngineNum | 是 | string | 发动机号码 |
+ VinNum | 是 | string | 车辆识别代号/车架号码 |
+ ImportCertificateNum | 是 | string | 进口证明书号 |
+ TaxPaymentVoucherNum | 是 | string | 完税凭证号码 |
+ LimitPassenger | 是 | string | 限乘人数 |
+ TaxAuthor | 是 | string | 主管税务机关名称 |
+ TaxAuthorCode | 是 | string | 主管税务机关代码 |
+ Tonnage | 是 | string | 吨位 |
+ Price | 是 | string | 不含税价格 |
+ TaxRate | 是 | string | 税率 |
+ Tax | 是 | string | 税额 |
+ PriceTaxLow | 是 | string | 价税合计 |
+ Saler | 是 | string | 销货单位名称 |
+ SalerCode | 是 | string | 销货单位纳税人识别号 |
+ SalerBank | 是 | string | 销货单位开户银行 |
+ SalerAccountNum | 是 | string | 销货单位账号 |
+ SalerPhone | 是 | string | 销货单位电话 |
二手车销售发票返回信息
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
+ Purchaser | 是 | string | 买方单位/个人 |
+ PurchaserCode | 是 | string | 买方单位代码/身份证号 |
+ PurchaserAddress | 是 | string | 买方单位/个人住址 |
+ PurchaserPhone | 是 | string | 买方电话 |
+ Saler | 是 | string | 卖方单位/个人 |
+ SalerCode | 是 | string | 卖方单位代码/身份证号 |
+ SalerAddress | 是 | string | 卖方单位/个人住址 |
+ SalerPhone | 是 | string | 卖方电话 |
+ LicensePlateNum | 是 | string | 车牌照号 |
+ RegistrationCode | 是 | string | 登记证号 |
+ TotalCarPrice | 是 | string | 车价合计 |
+ TransferVehicleManagementOffice | 是 | string | 转入地车辆车管所名称 |
+ VehicleType | 是 | string | 车辆类型 |
+ ManuModel | 是 | string | 厂牌型号 |
+ VinNum | 是 | string | 车辆识别代号/车架号码 |
+ Operator | 是 | string | 经营、拍卖单位 |
+ OperatorAddress | 是 | string | 经营、拍卖单位地址 |
+ OperatorCode | 是 | string | 经营、拍卖单位纳税人识别号 |
+ OperatorBank | 是 | string | 开户银行及账号 |
+ OperatorPhone | 是 | string | 经营、拍卖单位电话 |
+ UsedCarMarket | 是 | string | 二手车市场 |
+ UsedCarMarketCode | 是 | string | 二手车市场纳税人识别号 |
+ UsedCarMarketAddress | 是 | string | 二手车市地址 |
+ UsedCarMarketBank | 是 | string | 二手车市场开户银行及账号 |
+ UsedCarMarketPhone | 是 | string | 二手车市场电话 |
查验结果错误码
查验结果(VerifyResult) | 查验结果信息(VerifyMessage) | 描述 |
---|---|---|
9999 | 查验失败 | 查验失败,业务出现异常,请提交工单咨询 |
0002 | 超过该张票当天查验次数 | 此发票今日查询次数已达上限(5次),请次日查询 |
0005 | 请求不合法 | 发票信息有误,请核对后再查询 |
0006 | 发票信息不一致 | 发票信息有误,请核对后再查询 |
0009 | 发票不存在 | 所查发票不存在 |
1004 | 已超过最大查验量 | 已超过最大查验量,请提交工单咨询 |
1005 | 查询发票不规范 | 信息有误,请核对后再查询 |
1006 | 查验异常 | 发票信息有误,请核对后再查询 |
1007 | 该批次已过期,请重新更换批次号查验 | 该批次已过期,请重新更换批次查验 |
1008 | 字段不能为空 | 发票请求参数不能为空 |
1009 | 参数长度不正确 | 参数长度不符合规范,确认参数,再次查验 |
1014 | 日期当天的不能查验 | 日期当天的不能查验,请隔天再查 |
1015 | 超过5年的不能查验 | 超过5年的不能查验 |
1020 | 没有查验权限 | 没有查验权限,请提交工单咨询 |
1021 | 网络超时 | 税局维护升级,暂时无法查验,请提交工单咨询 |
返回示例
1// 增值税专票、电子专票、普票、电子普通发票、卷票、通行费增值税电子普通发票、货物运输业增值税专用发票
2{
3 "words_result": {
4 "log_id": 1394226734160674816,
5 "words_result_num": 43,
6 "VerifyFrequency": "3",
7 "VerifyMessage": "查验成功发票一致",
8 "InvalidSign": "N",
9 "InvoiceType": "增值税普通发票(电子)",
10 "MachineCode": "661616300747",
11 "CheckCode": "67820461013285253079",
12 "InvoiceCode": "043002000111",
13 "InvoiceDate": "20210503",
14 "VerifyResult": "0001",
15 "InvoiceNum": "63509760"
16 "TaxControlNum": "",
17 "CommodityEndDate": [
18 {
19 "row": "1",
20 "word": ""
21 }
22 ],
23 "VehicleTonnage": "",
24 "CommodityVehicleType": [
25 {
26 "row": "1"
27 }
28 ],
29 "CommodityStartDate": [
30 {
31 "row": "1",
32 "word": ""
33 }
34 ],
35 "SellerAddress": "湖南省长沙市天心区芙蓉中路三段446号0731-83592079",
36 "CommodityPrice": [
37 {
38 "row": "1",
39 "word": "28.20000000"
40 }
41 ],
42 "TransportCargoInformation": "",
43 "NoteDrawer": "",
44 "CommodityNum": [
45 {
46 "row": "1",
47 "word": "1.00000000"
48 }
49 ],
50 "SellerRegisterNum": "914301007121984812",
51 "SellerBank": "建行长沙铁银支行营业部43001710661050003739",
52 "Remarks": "账期:202104",
53 "TotalTax": "0.00",
54 "CommodityTaxRate": [
55 {
56 "row": "1",
57 "word": "不征税"
58 }
59 ],
60 "CommodityExpenseItem": [
61 {
62 "row": "1",
63 "word": ""
64 }
65 ],
66 "ZeroTaxRateIndicator": "",
67 "Carrier": "",
68 "SenderCode": "",
69 "PurchaserRegisterNum": "911101087877515792",
70 "ReceiverCode": "",
71 "AmountInFiguers": "28.20",
72 "PurchaserBank": "招商银行北京分行大屯路支行 866182028510003",
73 "Checker": "",
74 "TollSign": "",
75 "VehicleTypeNum": "",
76 "DepartureViaArrival": "",
77 "Receiver": "",
78 "Recipient": "",
79 "TotalAmount": "28.20",
80 "CommodityAmount": [
81 {
82 "row": "1",
83 "word": "28.20"
84 }
85 ],
86 "PurchaserName": "百度时代网络技术(北京)有限公司",
87 "CommodityType": [
88 {
89 "row": "1",
90 "word": ""
91 }
92 ],
93 "Sender": "",
94 "PurchaserAddress": "北京市海淀区东北旺西路8号中关村软件园17号楼二层A201059108001",
95 "CommodityTax": [
96 {
97 "row": "1",
98 "word": "***"
99 }
100 ],
101 "CarrierCode": "",
102 "CommodityPlateNum": [
103 {
104 "row": "1",
105 "word": ""
106 }
107 ],
108 "CommodityUnit": [
109 {
110 "row": "1",
111 "word": ""
112 }
113 ],
114 "Payee": "",
115 "RecipientCode": "",
116 "CommodityName": [
117 {
118 "row": "1",
119 "word": "*电信服务*通讯费服务费"
120 }
121 ],
122 "SellerName": "中国移动通信集团湖南有限公司长沙分公司"
123 },
124}
125// 机动车销售发票
126{
127 "words_result": {
128 "log_id": 1394232842988290048,
129 "words_result_num": 24,
130 "VerifyFrequency": "1",
131 "VerifyMessage": "查验成功发票一致",
132 "InvalidSign": "N",
133 "InvoiceType": "机动车销售统一发票",
134 "MachineCode": "539927983",
135 "CheckCode": "",
136 "InvoiceCode": "13200378019836",
137 "InvoiceDate": "20210128",
138 "VerifyResult": "0001",
139 "InvoiceNum": "00342061"
140 "Origin": "中国",
141 "ManuModel": "东风日产牌DFL8",
142 "SalerBank": "工行支行",
143 "VehicleType": "多用途乘用车",
144 "Tax": "18238.29",
145 "TaxPaymentVoucherNum": "",
146 "CommodityInspectionNum": "",
147 "TaxAuthorCode": "1332803841100",
148 "VinNum": "LGBM464574",
149 "SalerPhone": "0513-8237861",
150 "LimitPassenger": "5",
151 "PurchaserCode": "211402199410176136",
152 "TaxAuthor": "国家税务总局海门市税务局三厂税务分局",
153 "Tonnage": "",
154 "ImportCertificateNum": "",
155 "Saler": "海门市海通汽车销售服务有限公司",
156 "SalerAccountNum": "1111527109002888833",
157 "Price": "145840.71",
158 "CertificateNum": "WAC224003769810",
159 "TaxRate": "13%",
160 "Purchaser": "郑如意",
161 "SalerCode": "9132068478280000007164",
162 "EngineNum": "43380M",
163 "PriceTaxLow": "1323800"
164 },
165}
166// 二手车销售发票
167{
168 "words_result": {
169 "log_id": 1394233936539811840,
170 "words_result_num": 25,
171 "VerifyFrequency": "1",
172 "VerifyMessage": "查验成功发票一致",
173 "InvalidSign": "N",
174 "InvoiceType": "二手车销售统一发票",
175 "MachineCode": "66173004789204",
176 "CheckCode": "",
177 "InvoiceCode": "0323789200007",
178 "InvoiceDate": "20200509",
179 "VerifyResult": "0001",
180 "InvoiceNum": "002890341"
181 "Operator": "",
182 "TransferVehicleManagementOffice": "苏州市车管所",
183 "ManuModel": "JF1SH95F",
184 "RegistrationCode": "3200478903518",
185 "OperatorPhone": "",
186 "PurchaserCode": "320503782902308u425",
187 "Saler": "张散文",
188 "UsedCarMarketCode": "91320378038NCQUQXA",
189 "Purchaser": "张丽",
190 "OperatorCode": "",
191 "UsedCarMarketBank": "中国农业银行股份有限公司苏州分行清算中心10549001040001493",
192 "SalerAddress": "江苏省苏州市工业园区倪浜路3号",
193 "SalerCode": "411524199001016511",
194 "PurchaserPhone": "0",
195 "LicensePlateNum": "苏U1A666",
196 "VehicleType": "小型越野客车",
197 "OperatorBank": "",
198 "OperatorAddress": "",
199 "VinNum": "JF1SH78006596636",
200 "TotalCarPrice": "66000.00",
201 "SalerPhone": "",
202 "PurchaserAddress": "江苏省苏州市相城区元和莫阳村",
203 "UsedCarMarketPhone": "13182680222",
204 "UsedCarMarketAddress": "苏州高新区长江路668号(3号厂房)",
205 "UsedCarMarket": "苏州车市界二手车电子商务有限公司"
206 },
207}
医疗发票识别
支持识别全国各地门诊/住院发票的 业务流水号、发票号、住院号、门诊号、病例号、姓名、性别、社保卡号、金额大/小写、收款单位、省市、医保统筹支付、个人账户支付 等关键字段,其中北京/广东/河北/河南/江苏/山东/上海/天津/浙江等地区票据识别效果较佳。支持识别收费项目明细,并可根据不同省市地区返回对应的识别参数。
1 public void medicalInvoice() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4
5 // 调用医疗发票识别
6 JSONObject fileResult = client.medicalInvoice(image, null);
7 JSONObject urlResult = client.medicalInvoiceUrl(url, null);
8 System.out.println("fileResult:"+fileResult);
9 System.out.println("urlResult:"+urlResult);
10
11 // 如果有可选参数
12 HashMap<String, Object> option = new HashMap<>();
13 option.put("probability", "true");
14 JSONObject fileResultOption = client.medicalInvoice(image, option);
15 JSONObject urlResultOption = client.medicalInvoiceUrl(url, option);
16 System.out.println("fileResultOption:"+fileResultOption);
17 System.out.println("urlResultOption:"+urlResultOption);
18 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
location | 否 | string | true/false | 是否返回字段的位置信息,默认为 false,可缺省- false:不返回字段位置信息- true:返回字段的位置信息,包括上边距(top)、左边距(left)、宽度(width)、高度(height) |
probability | 否 | string | true/false | 是否返回字段识别结果的置信度,默认为 false,可缺省- false:不返回字段识别结果的置信度- true:返回字段识别结果的置信度,包括字段识别结果中各字符置信度的平均值(average)和最小值(min) |
返回参数详情
字段 | 是否必输出 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 调用日志id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
InvoiceType | 是 | string | 票据种类 |
Province | 是 | string | 省市:支持返回以下省市 北京/广东/河北/河南/江苏/山东/上海/天津/浙江等 |
words_result | 是 | object | 识别结果 |
+ BusinessNum | 是 | object | 业务流水号 |
+ InvoiceNum | 是 | object | 发票号码 |
+ HospitalNum | 是 | object | 住院号 |
+ HospitalName | 是 | object | 医院名称 |
+ RecordNum | 是 | object | 病例号 |
+ HospitalDay | 是 | object | 住院天数 |
+ AdmissionDate | 是 | object | 入院时间 |
+ DischargeDate | 是 | object | 出院时间 |
+ Name | 是 | object | 姓名 |
+ Sex | 是 | object | 性别 |
+ HospitalType | 是 | object | 医疗机构类型 |
+ SocialSecurityNum | 是 | object | 社保卡号 |
+ InsuranceType | 是 | object | 医保类型 |
+ ChargingUnit | 是 | object | 收款单位 |
+ Payee | 是 | object | 收款人 |
+ Date | 是 | object | 开票日期 |
+ AmountInWords | 是 | object | 大写合计金额 |
+ AmountInFiguers | 是 | object | 小写合计金额 |
+ InsurancePayment | 是 | object | 医保统筹支付 |
+ PersonalPayment | 是 | object | 个人账户支付 |
+ PrepayAmount | 是 | object | 预缴金额 |
+ PaymentAmount | 是 | object | 补缴金额 |
+ RefundAmount | 是 | object | 退费金额 |
+ ClinicNum | 是 | object | 门诊号 |
++ word | 是 | string | 字段识别结果,以上各字段均包含此参数 |
++ location | 否 | object | 字段位置信息,当请求参数 location=true 时,以上各字段均包含此参数 |
+++ top | 否 | uint32 | 字段的上边距 |
+++ left | 否 | uint32 | 字段的左边距 |
+++ height | 否 | uint32 | 字段的高度 |
+++ width | 否 | uint32 | 字段的宽度 |
++ probability | 否 | object | 字段识别结果置信度,当请求参数 probability=true 时,以上各字段均包含此参数 |
+++ average | 否 | float | 字段识别结果中各字符的置信度平均值 |
+++ min | 否 | float | 字段识别结果中各字符的置信度最小值 |
+ CostCategories | 是 | array[] | 项目大类:治疗费、检查费等项目大类 |
+ CostDetail | 是 | array[] | 明细类别:药物/检查的明细类别 |
+ RegionSupplement | 是 | array[] | 地区字段:根据省市返回改地区特有的字段 |
CostCategories字段包含多个array,每个数组包含多个object,见以下参数 |
字段 | 说明 |
---|---|
++ name | 字段名,包括:收费项目、金额 |
++ word | name字段对应的识别结果 |
CostDetail字段包含多个array,每个数组包含多个object,见以下参数 |
字段 | 说明 |
---|---|
++ name | 字段名,包括:编码、项目、规格、数量、单价、金额 |
++ word | name字段对应的识别结果 |
RegionSupplement字段包含多个object,不同省市返回字段不同,见以下参数 |
省市 | 返回参数(name) |
---|---|
北京 | 个人支付金额、其他医保支付、交易流水号、基金支付、单位补充险[原公疗]支付、年度门诊大额累计支付、本次医保范围内金额、本次支付后个人账户余额、残军补助支付、累计医保内范围金额、自付一、自付二、自费、起付金额、超封顶金额、退休补充支付、门诊大额支付 |
广东 | 个人支付金额、其他医保支付 |
河北 | 个人账户余额、统筹累计支付、自负、自费、起付标准 |
河南 | 个人支付金额、其他医保支付 |
江苏 | 个人支付金额、其他医保支付 |
山东 | 个人支付金额、其他医保支付 |
上海 | 分类自负、历年余额、本年余额、现金支付、自负、自费、附加支付 |
天津 | 个人支付金额、其他医保支付 |
浙江 | 历年余额、历年支付、基金支付、本年余额、本年支付、现金支付 |
返回示例
1{
2 "log_id": 1397076899313745920,
3 "words_result_num": 28,
4 "Province": "北京",
5 "InvoiceType": "门诊发票"
6 "words_result": {
7 "AmountInWords": {
8 "word": "玖佰叁拾玖元肆角捌分"
9 },
10 "Sex": {
11 "word": "男"
12 },
13 "InsuranceType": {
14 "word": "城镇职工"
15 },
16 "Name": {
17 "word": "王成"
18 },
19 "SocialSecurityNum": {
20 "word": "T03419700077"
21 },
22 "DischargeDate": {
23 "word": "2016-01-01"
24 },
25 "HospitalNum": {
26 "word": "0937829032"
27 },
28 "HospitalName": {
29 "word": "北京市房山区良乡医院"
30 },
31 "CostCategories": [
32 [
33 {
34 "name": "收费项目",
35 "word": "西药费"
36 },
37 {
38 "name": "金额",
39 "word": "426.70"
40 }
41 ],
42 [
43 {
44 "name": "收费项目",
45 "word": "中成药费"
46 },
47 {
48 "name": "金额",
49 "word": "512.78"
50 }
51 ]
52 ],
53 "RegionSupplement": [
54 {
55 "name": "其他医保支付",
56 "word": "0.00"
57 },
58 {
59 "name": "年度门诊大额累计支付",
60 "word": "83.79"
61 },
62 {
63 "name": "起付金额",
64 "word": "777.11"
65 },
66 {
67 "name": "基金支付",
68 "word": "101.75"
69 },
70 {
71 "name": "本次支付后个人账户余额",
72 "word": "0.00"
73 },
74 {
75 "name": "个人支付金额",
76 "word": "837.73"
77 },
78 {
79 "name": "交易流水号",
80 "word": "111100030Z160517006328"
81 },
82 {
83 "name": "自付一",
84 "word": "795.06"
85 },
86 {
87 "name": "自付二",
88 "word": "42.67"
89 },
90 {
91 "name": "累计医保内范围金额",
92 "word": "1419.70"
93 },
94 {
95 "name": "门诊大额支付",
96 "word": "83.79"
97 },
98 {
99 "name": "本次医保范围内金额",
100 "word": "896.81"
101 },
102 {
103 "name": "退休补充支付",
104 "word": "17.96"
105 },
106 {
107 "name": "超封顶金额",
108 "word": "0.00"
109 },
110 {
111 "name": "残军补助支付",
112 "word": "0.00"
113 },
114 {
115 "name": "单位补充险[原公疗]支付",
116 "word": "0.00"
117 },
118 {
119 "name": "自费",
120 "word": "42.67"
121 }
122 ],
123 "ClinicNum": {
124 "word": "12169298"
125 },
126 "AmountInFiguers": {
127 "word": "939.48"
128 },
129 "AdmissionDate": {
130 "word": "2016-01-01"
131 },
132 "HospitalType": {
133 "word": "综合医院"
134 },
135 "RefundAmount": {
136 "word": "0.00"
137 },
138 "Date": {
139 "word": "2016年05月17日"
140 },
141 "ChargingUnit": {
142 "word": "房山区良乡医院"
143 },
144 "CostDetail": [
145 [
146 {
147 "name": "编码",
148 "word": "01"
149 },
150 {
151 "name": "项目",
152 "word": "阿托伐他汀钙胶囊"
153 },
154 {
155 "name": "规格",
156 "word": "10mg*7支"
157 },
158 {
159 "name": "数量",
160 "word": "10"
161 },
162 {
163 "name": "单价",
164 "word": "29.3200"
165 },
166 {
167 "name": "金额",
168 "word": "293.20"
169 }
170 ],
171 [
172 {
173 "name": "编码",
174 "word": "02"
175 },
176 {
177 "name": "项目",
178 "word": "替米沙坦胶囊"
179 },
180 {
181 "name": "规格",
182 "word": "40mg*12粒"
183 },
184 {
185 "name": "数量",
186 "word": "5"
187 },
188 {
189 "name": "单价",
190 "word": "26.7000"
191 },
192 {
193 "name": "金额",
194 "word": "133.50"
195 }
196 ],
197 ],
198 "PaymentAmount": {
199 "word": "0.00"
200 },
201 "PrepayAmount": {
202 "word": "0.00"
203 },
204 "PersonalPayment": {
205 "word": "0.00"
206 },
207 "HospitalDay": {
208 "word": "15"
209 },
210 "BusinessNum": {
211 "word": "40091198916051710196"
212 },
213 "InsurancePayment": {
214 "word": "0.00"
215 },
216 "Payee": {
217 "word": "刘冰"
218 },
219 "RecordNum": {
220 "word": "0001268129"
221 },
222 "InvoiceNum": {
223 "word": "0103152099"
224 }
225 },
226}
公式识别
支持对试卷中的数学公式及题目内容进行识别,可提取公式部分进行单独识别,也可对题目和公式进行混合识别,并返回Latex格式公式内容及位置信息,便于进行后续处理。
1 public void formula() {
2 byte[] image = readFile("文件或图片路径");
3 String url = "https://www.x.com/sample.jpg";
4
5 // 调用公式识别
6 JSONObject fileResult = client.formula(image, null);
7 JSONObject urlResult = client.formulaUrl(url, null);
8 System.out.println("fileResult:"+fileResult);
9 System.out.println("urlResult:"+urlResult);
10
11 // 如果有可选参数
12 HashMap<String, Object> option = new HashMap<>();
13 option.put("recognize_granularity", "small");
14 JSONObject fileResultOption = client.formula(image, option);
15 JSONObject urlResultOption = client.formulaUrl(url, option);
16 System.out.println("fileResultOption:"+fileResultOption);
17 System.out.println("urlResultOption:"+urlResultOption);
18 }
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效 |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效请注意关闭URL防盗链 |
recognize_granularity | 否 | string | big/small | 是否定位单字符位置,big:不定位单字符位置;small:定位单字符位置。默认值为big |
detect_direction | 否 | bool | true/false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
disp_formula | 否 | bool | true/false | 是否分离输出公式识别结果,在words_result外单独输出公式结果,展示在“formula_result”中 |
返回参数详情 |
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | int32 | 图像方向,当detect_direction=true时存在。 - - 1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
formula_result | 否 | bool | 是否返回单独公式识别结果,默认false |
formula_result_num | 否 | bool | 识别结果中的公式个数,表示formula_result的元素个数 |
words_result | 是 | array[] | 识别结果数组 |
+ location | 是 | object{} | 位置数组(坐标0点为左上角) |
++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
+ words | 是 | string | 识别结果字符串 |
返回示例
1{
2 "log_id": 2671713289176456793,
3 "direction": 0,
4 "formula_result_num": 3,
5 "formula_result": [
6 {
7 "location": {
8 "width": 258,
9 "top": 265,
10 "left": 450,
11 "height": 204
12 },
13 "words": "\\left\\{ \\begin{aligned} & x = - 1 1 \\\\ & y = 2 \\\\ \\end{aligned} \\right. "
14 },
15 {
16 "location": {
17 "width": 429,
18 "top": 546,
19 "left": 310,
20 "height": 203
21 },
22 "words": "\\left\\{ \\begin{aligned} & 3 x + 2 y = m \\\\ & n x - y = 2 \\\\ \\end{aligned} \\right. "
23 },
24 {
25 "location": {
26 "width": 142,
27 "top": 613,
28 "left": 1029,
29 "height": 71
30 },
31 "words": "m - \\left[ 1 0 0 , - \\infty \\right) "
32 }
33 ],
34 "words_result_num": 5,
35 "words_result": [
36 {
37 "location": {
38 "width": 168,
39 "top": 313,
40 "left": 292,
41 "height": 110
42 },
43 "words": "已知"
44 },
45 {
46 "location": {
47 "width": 258,
48 "top": 265,
49 "left": 450,
50 "height": 204
51 },
52 "words": "\\left\\{ \\begin{aligned} & x = - 1 1 \\\\ & y = 2 \\\\ \\end{aligned} \\right. "
53 },
54 {
55 "location": {
56 "width": 582,
57 "top": 319,
58 "left": 728,
59 "height": 84
60 },
61 "words": "是二元一次方程组"
62 },
63 {
64 "location": {
65 "width": 429,
66 "top": 546,
67 "left": 310,
68 "height": 203
69 },
70 "words": "\\left\\{ \\begin{aligned} & 3 x + 2 y = m \\\\ & n x - y = 2 \\\\ \\end{aligned} \\right."
71 },
72 {
73 "location": {
74 "width": 780,
75 "top": 597,
76 "left": 745,
77 "height": 88
78 },
79 "words": "的解,则 m - \\left[ 1 0 0 , - \\infty \\right) 的值是()"
80 }
81 ]
82}
门脸文字识别
针对含有门脸/门头的图片进行专项优化,支持识别门脸/门头上的文字内容。
1public void facade() {
2 byte[] image = readFile("文件或图片路径");
3
4 // 调用门脸文字识别
5 JSONObject fileResult = client.facade(image);
6 System.out.println("fileResult:"+fileResult);
7}
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,base64编码去除编码头(data:image/jpeg;base64),要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
words_result | 否 | array[] | 定位和识别结果数组 |
+ words | 否 | string | 识别结果字符串 |
+ score | 否 | float | words返回为主门脸名称的置信度评分 |
+ brief | 否 | string | 门脸副标题等周边描述 |
返回示例
1{
2 "log_id": 341559937361307312,
3 "words_result_num": 3,
4 "words_result": [
5 {
6 "words": "生活超市",
7 "brief": "家得利",
8 "score": 0.80533
9 },
10 {
11 "words": "火火火火锅",
12 "score": 0.0112433
13 },
14 {
15 "words": "天天好便利店",
16 "score': 0.188124
17 }
18 ]
19}
通信行程卡识别
可识别国内通信大数据行程卡页面截图中的手机号码、更新日期、途径地三个字段内容,并返回途径地的风险情况。
1public void sample(AipOcr client) {
2 // 参数为本地图片路径
3 String image = "test.jpg";
4 JSONObject res = client.travelCard(image);
5 System.out.println(res.toString(2));
6
7 // 参数为本地图片二进制数组
8 byte[] file = readImageFile(image);
9 res = client.travelCard(file);
10 System.out.println(res.toString(2));
11}
请求参数
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的日志id,用于问题定位 |
result | 是 | object | 识别结果 |
+ 手机号 | 是 | array | 手机号 |
+ 途径地 | 是 | array | 到达或途径的城市信息 |
+ 更新时间 | 是 | array | 该通行信息的更新时间,可用于与当前时间比对查验时效性 |
+ 风险性 | 是 | bool | 返回值范围:true/false,若途径城市存在中高风险地区(带号),则该值返回为true,因新版行程卡取消号展示,该字段将固定返回false |
++ words | 是 | string | 字段识别内容 |
++ location | 是 | object | 位置数组(坐标0点为左上角) |
+++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
+++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
error_code | 是 | uint64 | 错误码,error_code=0 表明识别无误,其他返回结果表示识别出错,详情请查看 https://ai.baidu.com/ai-doc/OCR/dk3h7y5vr |
error_msg | 是 | string | 错误信息 |
返回示例
1{
2 "error_code":0,
3 "error_msg":"",
4 "log_id":"146756929847144448",
5 "result":{
6 "手机号":[
7 {
8 "location":{
9 "top":443,
10 "left":156,
11 "width":219,
12 "height":53
13 },
14 "word":[
15 "132****6231"
16 ]
17 }
18 ],
19 "途经地":[
20 {
21 "location":{
22 "top":1004,
23 "left":76,
24 "width":581,
25 "height":223
26 },
27 "word":[
28 "上海市",
29 "浙江省杭州市",
30 "福建省"
31 ]
32 }
33 ],
34 "风险性":true,
35 "更新时间":[
36 {
37 "location":{
38 "top":515,
39 "left":282,
40 "width":330,
41 "height":52
42 },
43 "word":[
44 "2021.08.04 21:17:31"
45 ]
46 }
47 ]
48 }
49}
健康码识别
可识别国内各省市健康码截图或拍摄照片中的姓名、更新时间、健康状态三个字段内容。
1public void sample(AipOcr client) {
2 // 参数为本地图片路径
3 String image = "test.jpg";
4 JSONObject res = client.healthCode(image);
5 System.out.println(res.toString(2));
6
7 // 参数为本地图片二进制数组
8 byte[] file = readImageFile(image);
9 res = client.healthCode(file);
10 System.out.println(res.toString(2));
11}
请求参数
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的日志id,用于问题定位 |
result | 是 | object | 识别结果 |
+ 姓名 | 是 | array | 健康码姓名 |
+ 更新时间 | 是 | array | 健康码更新时间 |
+ 状态 | 是 | array | |
++ words | 是 | string | 字段识别内容 |
++ location | 是 | object | 位置数组(坐标0点为左上角) |
+++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
+++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
error_code | 是 | uint64 | 错误码,error_code=0 表明识别无误,其他返回结果表示识别出错,详情请查看 https://ai.baidu.com/ai-doc/OCR/dk3h7y5vr |
error_msg | 是 | string | 错误信息 |
返回示例
1{
2 "姓名": [
3 {
4 "word": "**佳",
5 "location": {
6 "height": 58,
7 "top": 164,
8 "width": 98,
9 "left": 329
10 }
11 }
12 ],
13 "状态": [
14 {
15 "word": "绿码",
16 "location": {
17 "height": 38,
18 "top": 690,
19 "width": 69,
20 "left": 380
21 }
22 }
23 ],
24 "更新时间": [
25 {
26 "word": "2022-07-03 16:43:09",
27 "location": {
28 "height": 52,
29 "top": 998,
30 "width": 486,
31 "left": 34
32 }
33 }
34 ],
35 "log_id": 1543887780872961511
36}
核酸证明识别
可识别国内各省市电子核酸证明截图或拍摄照片中的姓名、检测时间、检测结果三个字段内容,暂不支持纸质核酸证明识别。
1public void sample(AipOcr client) {
2 // 参数为本地图片路径
3 String image = "test.jpg";
4 JSONObject res = client.covidTest(image);
5 System.out.println(res.toString(2));
6
7 // 参数为本地图片二进制数组
8 byte[] file = readImageFile(image);
9 res = client.covidTest(file);
10 System.out.println(res.toString(2));
11}
请求参数
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的日志id,用于问题定位 |
result | 是 | object | 识别结果 |
+ 姓名 | 是 | array | 核酸证明姓名 |
+ 检测时间 | 是 | array | 该核酸结果的检测时间,可用于与当前时间比对检测时效性 |
+ 检测结果 | 是 | array | 核酸检测结果,返回结果为“阴性/阳性/其他”,建议返回结果非“阴性”则进行人工校验 |
++ words | 是 | string | 字段识别内容 |
++ location | 是 | object | 位置数组(坐标0点为左上角) |
+++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
+++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
+++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
+++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
返回示例
1{
2 "姓名": [
3 {
4 "word": "*佳",
5 "location": {
6 "height": 28,
7 "top": 754,
8 "width": 45,
9 "left": 580
10 }
11 }
12 ],
13 "检测结果": [
14 {
15 "word": "阴性",
16 "location": {
17 "height": 73,
18 "top": 441,
19 "width": 178,
20 "left": 304
21 }
22 }
23 ],
24 "检测时间": [
25 {
26 "word": "2022-06-30 18:31:30",
27 "location": {
28 "height": 24,
29 "top": 1037,
30 "width": 226,
31 "left": 404
32 }
33 }
34 ],
35 "log_id": 1543890667962890449
36}
图文转换器(接口版)--提交请求
图文转换器对应的接口版产品,可识别图片/PDF文件中的文本内容,进行智能版式分析,并转换为保留原文档版式的Word、Excel文档,返回文档下载连接,支持含表格、印章、手写等内容的文档。满足文档版式还原、企业档案电子化等信息管理需求。如需直接在线使用轻应用,可到控制台-图文转换器使用。
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 // 参数为本地图片路径
6 String image = "test.jpg";
7 JSONObject res = client.docConvertRequestV1(image, options);
8 System.out.println(res.toString(2));
9 // 参数为url
10 String url = "http://test.jpg";
11 JSONObject res = client.docConvertRequestV1Url(url, options);
12 System.out.println(res.toString(2));
13 // 参数为本地pdf
14 String pdf_file = "test.pdf";
15 JSONObject res = client.docConvertRequestV1Pdf(pdf_file, options);
16 System.out.println(res.toString(2));
17
18 // 参数为本地图片二进制数组
19 byte[] file = readImageFile(image);
20 res = client.docConvertRequestV1(file, options);
21 System.out.println(res.toString(2));
22 }
请求参数
参数 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 和 url/pdf_file 三选一 | string | 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式优先级: image > url > pdf_file,当image字段存在时,url、pdf_file字段失效 |
url | 和 image/pdf_file 三选一 | string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式优先级: image > url > pdf_file,当image字段存在时url字段失效请注意关闭URL防盗链 |
pdf_file | 和 image/url 三选一 | string | PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不不超过10M优先级: image > url > pdf_file,当image、url字段存在时,pdf_file字段失效 |
pdf_file_num | 否 | string | 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容;若不传入,默认识别文件所有页,页码从1开始 |
返回参数
字段 | 类型 | 说明 |
---|---|---|
success | bool | 当前请求状态; true 表示请求成功,false表示请求异常 |
log_id | uint64 | 唯一的log id,用于问题定位 |
result | dict | 返回的结果列表 |
+ task_id | string | 该请求生成的task_id,后续使用该task_id获取识别结果 |
code | int | 成功状态码 |
message | string | 详情 |
返回示例
成功返回示例:
1{
2 "success":true,
3 "log_id": 12345,
4 "result":{
5 "task_id":"task-xxxxxxx",
6 },
7 "code":1001,
8 "message": "Create task successfully!"
9}
失败返回示例(详细的错误码说明见API文档-错误码):
1{
2 "success":false,
3 "log_id": 12345,
4 "error_code": 216401,
5 "error_msg": "Create task failed!"
6}
图文转换器(接口版)--获取结果
1 public void sample(AipOcr client) {
2 // 传入可选参数调用接口
3 HashMap<String, String> options = new HashMap<String, String>();
4
5 String task_id = "xxxxx";
6
7 // 获取结果
8 JSONObject res = client.docConvertResultV1(task_id, options);
9 System.out.println(res.toString(2));
10
11 }
请求参数
参数 | 是否必选 | 类型 | 说明 |
---|---|---|---|
task_id | 是 | string | 发送提交请求时返回的task_id |
返回参数
字段 | 类型 | 说明 |
---|---|---|
success | bool | 当前请求状态; true表示请求成功,false表示请求异常 |
log_id | uint64 | 唯一的log id,用于问题定位 |
result | dict | 返回的结果列表 |
+ task_id | string | 该文件对应请求的task_id |
+ ret_code | int | 识别状态,1:任务未开始;2:进行中;3:已完成 |
+ ret_msg | string | 识别状态信息:任务未开始;进行中;已完成 |
+ percent | int | 文档转换进度(百分比) |
+ result_data | dict | 识别结果字符串,返回word、excel的文件分别的下载地址 |
+ +word | string | 还原后的word文件的下载地址,文件识别失败时返回"" |
+ +excel | string | 还原后的Excel文件的下载地址,若文档中没有表格则返回"" |
+ create_time | datetime | 任务创建时间 |
+ start_time | datetime | 任务开始时间 |
+ end_time | datetime | 任务结束时间 |
code | int | 成功状态码 |
message | string | 详情 |
返回示例
成功返回示例:
1{
2 "success":true,
3 "log_id": "xxxxxx",
4 "result":{
5 "task_id":"task-xxxxxxx",
6 "ret_code": 3,
7 "ret_msg": "已完成",
8 "percent": 100,
9 "result_data": {
10 "word": "word_download_url",
11 "excel": "",
12 },
13 "create_time": "2023-01-17 11:06:12",
14 "start_time": "2023-01-17 11:06:13",
15 "end_time": "2023-01-17 11:06:15"
16 },
17 "code":1001,
18 "message": "Query task successfully!""
19}
若查询的task_id不存在, 返回result为{}。 请求失败响应体示例如下:
1{
2 "code":1001,
3
4 "log_id":1635891796603052032,
5
6 "message":"Query task successfully!",
7
8 "result":{},
9
10 "success":true
11}
表格文字识别同步接口
接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别同步接口。
表格文字识别
接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别。
表格识别结果
接口已下线,请使用表格文字识别V2,历史版本可查看表格识别结果。