接口说明
通用文字识别
用户向服务请求识别某张图中的所有文字
1 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用文字识别, 图片参数为本地图片
7 result = client.general_basic(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["language_type"] = "CHN_ENG";
12 options["detect_direction"] = "true";
13 options["detect_language"] = "true";
14 options["probability"] = "true";
15
16 // 带参数调用通用文字识别, 图片参数为本地图片
17 result = client.general_basic(image, options);
18
19 Json::Value result;
20
21 std::string url = "https//www.x.com/sample.jpg";
22
23 // 调用通用文字识别, 图片参数为远程url图片
24 result = client.general_basic_url(url, aip::null);
25
26 // 如果有可选参数
27 std::map<std::string, std::string> options;
28 options["language_type"] = "CHN_ENG";
29 options["detect_direction"] = "true";
30 options["detect_language"] = "true";
31 options["probability"] = "true";
32
33 // 带参数调用通用文字识别, 图片参数为远程url图片
34 result = client.general_basic_url(url, options);
通用文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
url | 是 | std::string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
language_type | 否 | std::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 | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | std::string | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
probability | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用文字识别(高精度版)
7 result = client.accurate_basic(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["detect_direction"] = "true";
12 options["probability"] = "true";
13
14 // 带参数调用通用文字识别(高精度版)
15 result = client.accurate_basic(image, options);
通用文字识别(高精度版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
detect_direction | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
probability | 否 | std::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": 1390582998516105216,
3 "words_result_num": 2
4 "words_result": [
5 {
6 "words": " OCR"
7 },
8 {
9 "words": "百度通用文字识别高精度版"
10 }
11 ]
12}
通用文字识别(含位置信息版)
用户向服务请求识别某张图中的所有文字,并返回文字在图中的位置信息。
1 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用文字识别(含位置信息版), 图片参数为本地图片
7 result = client.general(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["recognize_granularity"] = "big";
12 options["language_type"] = "CHN_ENG";
13 options["detect_direction"] = "true";
14 options["detect_language"] = "true";
15 options["vertexes_location"] = "true";
16 options["probability"] = "true";
17
18 // 带参数调用通用文字识别(含位置信息版), 图片参数为本地图片
19 result = client.general(image, options);
20
21 Json::Value result;
22
23 std::string url = "https//www.x.com/sample.jpg";
24
25 // 调用通用文字识别(含位置信息版), 图片参数为远程url图片
26 result = client.general_url(url, aip::null);
27
28 // 如果有可选参数
29 std::map<std::string, std::string> options;
30 options["recognize_granularity"] = "big";
31 options["language_type"] = "CHN_ENG";
32 options["detect_direction"] = "true";
33 options["detect_language"] = "true";
34 options["vertexes_location"] = "true";
35 options["probability"] = "true";
36
37 // 带参数调用通用文字识别(含位置信息版), 图片参数为远程url图片
38 result = client.general_url(url, options);
通用文字识别(含位置信息版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
url | 是 | std::string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
recognize_granularity | 否 | std::string | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
language_type | 否 | std::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 | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | std::string | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
vertexes_location | 否 | std::string | true false |
false | 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false |
probability | 否 | std::string | true false |
是否返回识别结果中每一行的置信度 | |
paragraph | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用文字识别(含位置高精度版)
7 result = client.accurate(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["recognize_granularity"] = "big";
12 options["detect_direction"] = "true";
13 options["vertexes_location"] = "true";
14 options["probability"] = "true";
15
16 // 带参数调用通用文字识别(含位置高精度版)
17 result = client.accurate(image, options);
通用文字识别(含位置高精度版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
recognize_granularity | 否 | std::string | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
detect_direction | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
vertexes_location | 否 | std::string | true false |
false | 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false |
probability | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用文字识别(含生僻字版), 图片参数为本地图片
7 result = client.general_enhanced(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["language_type"] = "CHN_ENG";
12 options["detect_direction"] = "true";
13 options["detect_language"] = "true";
14 options["probability"] = "true";
15
16 // 带参数调用通用文字识别(含生僻字版), 图片参数为本地图片
17 result = client.general_enhanced(image, options);
18
19 Json::Value result;
20
21 std::string url = "https//www.x.com/sample.jpg";
22
23 // 调用通用文字识别(含生僻字版), 图片参数为远程url图片
24 result = client.general_enhanced_url(url, aip::null);
25
26 // 如果有可选参数
27 std::map<std::string, std::string> options;
28 options["language_type"] = "CHN_ENG";
29 options["detect_direction"] = "true";
30 options["detect_language"] = "true";
31 options["probability"] = "true";
32
33 // 带参数调用通用文字识别(含生僻字版), 图片参数为远程url图片
34 result = client.general_enhanced_url(url, options);
通用文字识别(含生僻字版) 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
url | 是 | std::string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
language_type | 否 | std::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 | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | std::string | true false |
false | 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) |
probability | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用网络图片文字识别, 图片参数为本地图片
7 result = client.webimage(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["detect_direction"] = "true";
12 options["detect_language"] = "true";
13
14 // 带参数调用网络图片文字识别, 图片参数为本地图片
15 result = client.webimage(image, options);
16
17 Json::Value result;
18
19 std::string url = "https//www.x.com/sample.jpg";
20
21 // 调用网络图片文字识别, 图片参数为远程url图片
22 result = client.webimage_url(url, aip::null);
23
24 // 如果有可选参数
25 std::map<std::string, std::string> options;
26 options["detect_direction"] = "true";
27 options["detect_language"] = "true";
28
29 // 带参数调用网络图片文字识别, 图片参数为远程url图片
30 result = client.webimage_url(url, options);
网络图片文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
url | 是 | std::string | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效 | ||
detect_direction | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_language | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 std::string id_card_side = "back";
7
8 // 调用身份证识别
9 result = client.idcard(image, id_card_side, aip::null);
10
11 // 如果有可选参数
12 std::map<std::string, std::string> options;
13 options["detect_direction"] = "true";
14 options["detect_risk"] = "false";
15
16 // 带参数调用身份证识别
17 result = client.idcard(image, id_card_side, options);
身份证识别 请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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防盗链 |
id_card_side | 是 | string | front/back | -front:身份证含照片的一面 -back:身份证带国徽的一面 自动检测身份证正反面,如果传参指定方向与图片相反,支持正常识别,返回参数image_status字段为"reversed_side" |
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[] | 定位和识别结果数组 |
words_result_num | 是 | uint32 | 识别结果数,表示words_result的元素个数 |
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 | 否 | object | 当请求参数 detect_photo = true时返回,头像的位置信息(坐标0点为左上角) |
card_image | 否 | string | 当请求参数 detect_card = true时返回,身份证裁剪切图的 base64 编码(无编码头,需自行处理) |
card_location | 否 | object | 当请求参数 detect_card = true时返回,身份证裁剪切图的位置信息(坐标0点为左上角) |
idcard_number_type | 是 | int | 用于校验身份证号码、性别、出生是否一致,输出结果及其对应关系如下: - 1: 身份证正面所有字段全为空 0: 身份证证号不合法,此情况下不返回身份证证号 1: 身份证证号和性别、出生信息一致 2: 身份证证号和性别、出生信息都不一致 3: 身份证证号和出生信息不一致 4: 身份证证号和性别信息不一致 |
+ location | 是 | array[] | 位置数组(坐标0点为左上角) |
++ left | 是 | uint32 | 表示定位位置的长方形左上顶点的水平坐标 |
++ top | 是 | uint32 | 表示定位位置的长方形左上顶点的垂直坐标 |
++ width | 是 | uint32 | 表示定位位置的长方形的宽度 |
++ height | 是 | uint32 | 表示定位位置的长方形的高度 |
+ 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}
银行卡识别
识别银行卡并返回卡号和发卡行。
1Json::Value result;
2
3std::string image;
4aip::get_file_content("/assets/sample.jpg", &image);
5
6// 调用银行卡识别
7result = client.bankcard(image, aip::null);
银行卡识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
银行卡识别 返回数据参数详情
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用驾驶证识别
7 result = client.driving_license(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["detect_direction"] = "true";
12
13 // 带参数调用驾驶证识别
14 result = client.driving_license(image, options);
驾驶证识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
detect_direction | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
驾驶证识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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": "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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用行驶证识别
7 result = client.vehicle_license(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["detect_direction"] = "true";
12 options["accuracy"] = "normal";
13
14 // 带参数调用行驶证识别
15 result = client.vehicle_license(image, options);
行驶证识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
detect_direction | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用车牌识别
7 result = client.license_plate(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["multi_detect"] = "true";
12
13 // 带参数调用车牌识别
14 result = client.license_plate(image, options);
车牌识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
multi_detect | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用营业执照识别
7 result = client.business_license(image, aip::null);
营业执照识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
detect_direction | 否 | std::string | 此参数新版本无需传,支持自动检测图像旋转角度;朝向是指输入图像是正常方向、逆时针旋转90/180/270度 |
accuracy | 否 | std::string | 此参数新版本无需传,可选值:normal,high |
risk_warn | 否 | std::string | 是否开启风险类型功能,默认不开启,即:false。false:不开启 true:开启 |
营业执照识别 返回数据参数详情
参数 | 是否必须 | 类型 | 说明 |
---|---|---|---|
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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 // 调用通用票据识别
7 result = client.receipt(image, aip::null);
8
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 options["recognize_granularity"] = "big";
12 options["probability"] = "true";
13 options["accuracy"] = "normal";
14 options["detect_direction"] = "true";
15
16 // 带参数调用通用票据识别
17 result = client.receipt(image, options);
通用票据识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
recognize_granularity | 否 | std::string | big - 不定位单字符位置 small - 定位单字符位置 |
small | 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 |
probability | 否 | std::string | true false |
是否返回识别结果中每一行的置信度 | |
accuracy | 否 | std::string | normal - 使用快速服务 |
normal 使用快速服务,1200ms左右时延;缺省或其它值使用高精度服务,1600ms左右时延 | |
detect_direction | 否 | std::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 Json::Value result;
2
3 std::string image;
4 aip::get_file_content("/assets/sample.jpg", &image);
5
6 std::string templateSign = "Nsdax2424asaAS791823112";
7
8 // 调用自定义模板文字识别
9 result = client.custom(image, templateSign, aip::null);
自定义模板文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
templateSign | 否 | std::string | 您在自定义文字识别平台制作的模板的ID |
classifierId | 否 | std::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}
增值税发票识别
支持对增值税普票、专票、卷票、电子发票、区块链发票的所有字段进行结构化识别,包括发票基本信息、销售方及购买方信息、商品信息、价税信息等,其中五要素字段的识别准确率超过 99.9%; 同时,支持对增值税卷票的 21 个关键字段进行识别,包括发票类型、发票代码、发票号码、机打号码、机器编号、收款人、销售方名称、销售方纳税人识别号、开票日期、购买方名称、购买方纳税人识别号、项目、单价、数量、金额、税额、合计金额(小写)、合计金额(大写)、校验码、省、市,四要素字段的识别准确率可达95%。
1 #include "ocr.h"
2
3 // 设置APPID/AK/SK
4 std::string app_id = "你的 App ID";
5 std::string api_key = "你的 Api key";
6 std::string secret_key = "你的 Secret Key";
7
8 aip::Ocr client(app_id, api_key, secret_key);
9 Json::Value result;
10 // 如果有可选参数
11 std::map<std::string, std::string> options;
12 std::string image;
13 //图片识别
14 aip::get_file_content("./sample.jpg", &image);
15 result = client.vatInvoice(image, options);
16 //url识别
17 result = client.vatInvoiceUrl("htpp://test.jpg", options);
18 //pdf识别
19 aip::get_file_content("./pdf.jpg", &image);
20 result = client.vatInvoicePdf(image, options);
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url或者pdf文件 |
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 #include "ocr.h"
2
3 // 设置APPID/AK/SK
4 std::string app_id = "你的 App ID";
5 std::string api_key = "你的 Api key";
6 std::string secret_key = "你的 Secret Key";
7
8 aip::Ocr client(app_id, api_key, secret_key);
9 Json::Value result;
10 // 如果有可选参数
11 std::map<std::string, std::string> options;
12
13 std::string image;
14 //图片识别
15 aip::get_file_content("./sample.jpg", &image);
16 result = client.taxiReceipt(image, options);
17 //url识别
18 result = client.taxiReceiptUrl("htpp://test.jpg", options);
19 **请求参数详情**
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片二进制数据或url |
返回参数
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
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 #include "ocr.h"
2
3 // 设置APPID/AK/SK
4 std::string app_id = "你的 App ID";
5 std::string api_key = "你的 Api key";
6 std::string secret_key = "你的 Secret Key";
7
8 aip::Ocr client(app_id, api_key, secret_key);
9 Json::Value result;
10 // 如果有可选参数
11 std::map<std::string, std::string> options;
12 std::string image;
13 //图片识别
14 aip::get_file_content("./sample.jpg", &image);
15 result = client.vinCode(image, options);
16 //url识别
17 result = client.vinCodeUrl("htpp://test.jpg", options);
18 **请求参数详情**
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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 #include "ocr.h"
2
3 // 设置APPID/AK/SK
4 std::string app_id = "你的 App ID";
5 std::string api_key = "你的 Api key";
6 std::string secret_key = "你的 Secret Key";
7
8 aip::Ocr client(app_id, api_key, secret_key);
9 Json::Value result;
10 // 如果有可选参数
11 std::map<std::string, std::string> options;
12 std::string image;
13 //图片识别
14 aip::get_file_content("./sample.jpg", &image);
15 result = client.trainTicket(image, options);
16 //url识别
17 result = client.trainTicketUrl("htpp://test.jpg", options);
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
返回参数
参数 | 类型 | 是否必须 | 说明 |
---|---|---|---|
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 #include "ocr.h"
2
3 // 设置APPID/AK/SK
4 std::string app_id = "你的 App ID";
5 std::string api_key = "你的 Api key";
6 std::string secret_key = "你的 Secret Key";
7
8 aip::Ocr client(app_id, api_key, secret_key);
9 Json::Value result;
10 // 如果有可选参数
11 std::map<std::string, std::string> options;
12 std::string image;
13 //图片识别
14 aip::get_file_content("./sample.jpg", &image);
15 result = client.numbers(image, options);
请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 印章识别
5 result = client.seal(image,aip::null);
6
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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 | 其他字段识别内容的置信度 |
返回示例
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}
网络图片文字识别(含位置版)
支持识别艺术字体或背景复杂的文字内容,除文字信息外,还可返回每行文字的位置信息、行置信度,以及单字符内容和位置等。
1 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 网络图片文字识别(含位置版)
5 result = client.webimageloc(image,aip::null);
6 // 文件url
7 std::string = "http://host/test.jpeg"
8 result = client.webimagelocurl(url,aip::null);
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 // 带参数调用网络图片文字识别(含位置版)
12 result = client.webimageloc(image, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,像素乘积不超过2048*2048 (1024*1024以内图像处理效果最佳)。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效 请注意关闭URL防盗链 |
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 | 表示定位定位位置的长方形的高度 |
返回示例
1{
2 "log_id": 1390656223866519552,
3 "words_result_num": 3,
4 "words_result": [
5 {
6 "words": "梦想起航",
7 "location": {
8 "top": 328,
9 "left": 1079,
10 "width": 56,
11 "height": 262
12 },
13 },
14 {
15 "words": "前往下一个目的地",
16 "location": {
17 "top": 329,
18 "left": 1160,
19 "width": 63,
20 "height": 446
21 },
22 },
23 {
24 "words": "开始新的旅程",
25 "location": {
26 "top": 455,
27 "left": 1246,
28 "width": 63,
29 "height": 340
30 },
31 }
32 ],
33}
仪器仪表盘读数识别
适用于不同品牌、不同型号的仪器仪表盘读数识别,广泛适用于各类血糖仪、血压仪、燃气表、电表等,可识别表盘上的数字、英文、符号,支持液晶屏、字轮表等表型。
1 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 仪器仪表盘读数识别
5 result = client.meter(image,aip::null);
6 // 文件url
7 std::string = "http://host/test.jpeg"
8 result = client.meterurl(url,aip::null);
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 // 带参数调用仪器仪表盘读数识别
12 result = client.meter(image, options);
13
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px。支持jpg/jpeg/png/bmp格式.注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效 请注意关闭URL防盗链 |
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{
2 "log_id": "1392680790663364608",
3 "words_result_num": 5
4 "words_result": [
5 {
6 "words": "5.8",
7 "location": {
8 "top": 150,
9 "left": 370,
10 "width": 87,
11 "height": 79
12 }
13 },
14 {
15 "words": "mmol/L",
16 "location": {
17 "top": 241,
18 "left": 402,
19 "width": 52,
20 "height": 12
21 }
22 },
23 {
24 "words": "10:38",
25 "location": {
26 "top": 115,
27 "left": 347,
28 "width": 42,
29 "height": 21
30 }
31 },
32 {
33 "words": "12-11",
34 "location": {
35 "top": 116,
36 "left": 410,
37 "width": 36,
38 "height": 20
39 }
40 },
41 {
42 "words": "am",
43 "location": {
44 "top": 115,
45 "left": 391,
46 "width": 12,
47 "height": 5
48 }
49 }
50 ],
51}
试卷分析与识别
可对文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景
1 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 试卷分析与识别
5 result = client.docanalysis(image,aip::null);
6 // 文件url
7 std::string = "http://host/test.jpeg"
8 result = client.docanalysisurl(url,aip::null);
9 // 如果有可选参数
10 std::map<std::string, std::string> options;
11 // 带参数调用试卷分析与识别
12 result = client.docanalysis(image, options);
13
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少64px,最长边最大4096px。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效 请注意关闭URL防盗链 |
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条展示) |
返回示例
1{
2 "results_num": 6,
3 "log_id": "4488766695474114139",
4 "img_direction": 0,
5 "layouts_num": 0,
6 "results": [
7 {
8 "words_type": "print",
9 "words": {
10 "words_location": {
11 "top": 124,
12 "left": 136,
13 "width": 418,
14 "height": 65
15 },
16 "word": "五默写(4分)"
17 },
18 },
19 {
20 "words_type": "print",
21 "words": {
22 "words_location": {
23 "top": 246,
24 "left": 136,
25 "width": 37,
26 "height": 45
27 },
28 "word": "1"
29 },
30 },
31 {
32 "words_type": "handwriting",
33 "words": {
34 "words_location": {
35 "top": 195,
36 "left": 237,
37 "width": 469,
38 "height": 104
39 },
40 "word": "采菊东篱下"
41 },
42 },
43 {
44 "words_type": "print",
45 "words": {
46 "words_location": {
47 "top": 241,
48 "left": 889,
49 "width": 287,
50 "height": 52
51 },
52 "word": "悠然见南山?"
53 },
54 },
55 {
56 "words_type": "print",
57 "words": {
58 "words_location": {
59 "top": 415,
60 "left": 134,
61 "width": 472,
62 "height": 52
63 },
64 "word": "2.商女不知亡国恨"
65 },
66 },
67 {
68 "words_type": "handwriting",
69 "words": {
70 "words_location": {
71 "top": 377,
72 "left": 607,
73 "width": 556,
74 "height": 93
75 },
76 "word": "隔江犹唱后庭花。"
77 },
78 },
79 ]
80}
手写文字识别
支持对图片中的手写中文、手写数字进行检测和识别,针对不规则的手写字体进行专项优化,识别准确率可达90%以上。
1 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 手写文字识别
5 result = client.handwriting(image,aip::null);
6 // 如果有可选参数
7 std::map<std::string, std::string> options;
8 // 带参数调用手写文字识别
9 result = client.handwriting(image, options);
10
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
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 }
办公文档识别
可对办公类文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景。
1 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 办公文档识别
5 result = client.docanalysisoffice(image,aip::null);
6 // 如果有可选参数
7 std::map<std::string, std::string> options;
8 // 带参数调用办公文档识别
9 result = client.docanalysisoffice(image, options);
10
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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 | 是否分析文档版面:包括图、表、标题、段落的分析输出 |
erase_seal | 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条展示) |
返回示例
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 Json::Value result;;
2 std::string image;
3 aip::get_file_content("/assets/sample.jpg", &image);
4 // 二维码识别
5 result = client.qrcode(image,aip::null);
6 // 如果有可选参数
7 std::map<std::string, std::string> options;
8 // 带参数调用二维码识别
9 result = client.qrcode(image, options);
10
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 是 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式 |
返回参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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}
试卷分析与识别
可对文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用试卷分析与识别
5result = client.docAnalysis(image, aip::null);
6std::string url =
7result = client.docAnalysisUrl(url, aip::null);
8// 如果有可选参数
9std::map<std::string, std::string> options;
10options["multi_detect"] = ""
11result = client.docAnalysis(image, options);
12result = client.docAnalysisUrl(image, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
image | 和url二选一 | string | - | 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少64px,最长边最大4096px。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,) |
url | 和image二选一 | string | - | 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效 请注意关闭URL防盗链 |
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条展示) |
返回示例
1{
2 "results_num": 6,
3 "log_id": "4488766695474114139",
4 "img_direction": 0,
5 "layouts_num": 0,
6 "results": [
7 {
8 "words_type": "print",
9 "words": {
10 "words_location": {
11 "top": 124,
12 "left": 136,
13 "width": 418,
14 "height": 65
15 },
16 "word": "五默写(4分)"
17 },
18 },
19 {
20 "words_type": "print",
21 "words": {
22 "words_location": {
23 "top": 246,
24 "left": 136,
25 "width": 37,
26 "height": 45
27 },
28 "word": "1"
29 },
30 },
31 {
32 "words_type": "handwriting",
33 "words": {
34 "words_location": {
35 "top": 195,
36 "left": 237,
37 "width": 469,
38 "height": 104
39 },
40 "word": "采菊东篱下"
41 },
42 },
43 {
44 "words_type": "print",
45 "words": {
46 "words_location": {
47 "top": 241,
48 "left": 889,
49 "width": 287,
50 "height": 52
51 },
52 "word": "悠然见南山?"
53 },
54 },
55 {
56 "words_type": "print",
57 "words": {
58 "words_location": {
59 "top": 415,
60 "left": 134,
61 "width": 472,
62 "height": 52
63 },
64 "word": "2.商女不知亡国恨"
65 },
66 },
67 {
68 "words_type": "handwriting",
69 "words": {
70 "words_location": {
71 "top": 377,
72 "left": 607,
73 "width": 556,
74 "height": 93
75 },
76 "word": "隔江犹唱后庭花。"
77 },
78 },
79 ]
80}
机动车销售发票
支持对机动车销售发票的26个关键字段进行结构化识别,包括发票代码、发票号码、开票日期、机器编号、购买方名称、购买方身份证号码/组织机构代码、车辆类型、厂牌型号、产地、合格证号、发动机号码、车架号码、价税合计、价税合计小写、销货单位名称、电话、纳税人识别号、账号、地址、开户银行、税率、税额、主管税务机关及代码、不含税价格、限乘人数
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用机动车销售发票
5result = client.vehicleInvoice(image, aip::null);
6std::string url =
7result = client.vehicleInvoiceUrl(url, aip::null);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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个关键字段进行结构化识别,包括合格证编号、发证日期、车辆制造企业名、车辆品牌、车辆名称、车辆型号、车架号、车身颜色、发动机型号、发动机号、燃料种类、排量、功率、排放标准、轮胎数、轴距、轴数、转向形式、总质量、整备质量、驾驶室准乘人数、最高设计车速、车辆制造日期
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用车辆合格证
5result = client.vehicleCertificate(image, aip::null);
6std::string url =
7result = client.vehicleCertificateUrl(url, aip::null);
8// 如果有可选参数
9std::map<std::string, std::string> options;
10options["language_type"] = ""
11options["result_type"] = ""
12options["detect_direction"] = ""
13options["line_probability"] = ""
14options["words_type"] = ""
15result = client.vehicleCertificate(image, options);
16result = client.vehicleCertificateUrl(image, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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 个字段进行结构化识别,包括户号、姓名、与户主关系、性别、出生地、民族、出生日期、身份证号、本市县其他住址、曾用名、籍贯、宗教信仰、身高、血型、文化程度、婚姻状况、兵役状况、服务处所、职业、何时由何地迁往本市、何时由何地迁往本址、登记日期
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用户口本识别
5result = client.householdRegister(image, aip::null);
6std::string url =
7result = client.householdRegisterUrl(url, aip::null);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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}
飞机行程单识别
支持对飞机行程单的24个字段进行结构化识别,包括电子客票号、印刷序号、姓名、始发站、目的站、航班号、日期、时间、票价、身份证号、承运人、民航发展基金、保险费、燃油附加费、其他税费、合计金额、填开日期、订票渠道、客票级别、座位等级、销售单位号、签注、免费行李、验证码。 同时,支持单张行程单上的多航班信息识别。
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用飞机行程单识别
5result = client.airTicket(image, aip::null);
6std::string url =
7result = client.airTicketUrl(url, aip::null);
8// 如果有可选参数
9std::map<std::string, std::string> options;
10options["multi_detect"] = ""
11result = client.airTicket(image, options);
12result = client.airTicketUrl(image, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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个关键字段进行结构化识别,包括发票类型、发票号码、发票代码、开票日期、合计金额大写、合计金额小写、商品名称、商品单位、商品单价、商品数量、商品金额、机打代码、机打号码、校验码、销售方名称、销售方纳税人识别号、购买方名称、购买方纳税人识别号、合计税额等。
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用通用机打发票
5result = client.invoice(image, aip::null);
6std::string url =
7result = client.invoiceUrl(url, aip::null);
8// 如果有可选参数
9std::map<std::string, std::string> options;
10options["location"] = ""
11result = client.invoice(image, options);
12result = client.invoiceUrl(image, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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。
1Json::Value result;
2std::string image;
3aip::get_file_content("/assets/sample.jpg", &image);
4// 调用护照识别
5result = client.passport(image, aip::null);
6std::string url =
7result = client.passportUrl(url, aip::null);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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 个关键字段。
1 Json::Value result;
2 std::string image;
3 aip::get_file_content("文件或图片路径", &image);
4 std::string pdf_file;
5 aip::get_file_content("文件或图片路径", &pdf_file);
6 std::string url = "https//www.x.com/sample.jpg"
7 // 调用网约车行程单识别
8 result = client.onlineTaxiItinerary(image);
9 result = client.onlineTaxiItineraryUrl(url);
10 result = client.onlineTaxiItineraryPdf(pdf_file,aip::null);
11 // 如果有可选参数
12 std::map<std::string, std::string> options;
13 options["pdf_file_num"] = 1
14 result = client.onlineTaxiItineraryPdf(pdf_file, options);
请求参数详情
参数 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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个关键字段,现阶段仅支持识别印刷体磅单。
1 Json::Value result;
2 std::string image;
3 aip::get_file_content("文件或图片路径", &image);
4 std::string url = "https//www.x.com/sample.jpg"
5 std::string pdf_file;
6 aip::get_file_content("文件或图片路径", &image);
7 // 调用磅单识别
8 result = client.weightNote(image,aip::null);
9 result = client.weightNoteUrl(url,aip::null);
10 result = client.weightNotePdf(pdf_file,aip::null);
11 // 如果有可选参数
12 std::map<std::string, std::string> options;
13 options["pdf_file_num"] = 1
14 options["probability"] = false
15 result = client.weightNote(image, options);
16 result = client.weightNoteUrl(url, options);
17 result = client.weightNotePdf(pdf_file, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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、总金额等关键字段,支持识别费用明细项目清单,包含项目类型、项目名称、单价、数量、规格、金额,其中北京地区识别效果最佳。
1 Json::Value result;
2 std::string url = "https//www.x.com/sample.jpg"
3 std::string image;
4 aip::get_file_content("文件或图片路径", &image);
5 // 调用医疗费用明细识别
6 result = client.medicalDetail(image,aip::null);
7 result = client.medicalDetailUrl(url,aip::null);
8 // 如果有可选参数
9 std::map<std::string, std::string> options;
10 options["location"] = true
11 options["probability"] = false
12 result = client.medicalDetail(image, options);
13 result = client.medicalDetailUrl(url, options);
请求参数详情
参数 | 是否必选 | 类型 | 可选值范围 | 说明 |
---|---|---|---|---|
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}
彩票识别
SDK 调用示例
1 Json::Value result;
2 std::string image;
3 aip::get_file_content("文件或图片路径", &image);
4 std::string url = "https//www.x.com/sample.jpg"
5
6 // 调用彩票识别
7 result = client.lottery_v1(image, options);
8 result = client.lottery_v1_url(url, options);
接口详情
可参考API文档:彩票识别
iOCR通用版
SDK 调用示例
1 Json::Value result;
2 std::string image;
3 std::string pdf_file;
4 aip::get_file_content("文件或图片路径", &image);
5 std::string url = "https//www.x.com/sample.jpg"
6 aip::get_file_content("文件或图片路径", &pdf_file);
7
8 // 调用iOCR通用版
9 result = client.recognise_iocr_v1(image, aip::null);
10 result = client.recognise_iocr_v1_url(url, aip::null);
11 result = client.recognise_iocr_v1_pdf(pdf_file, aip::null);
接口详情
可参考API文档:iOCR通用版
出生证明识别
SDK 调用示例
1 Json::Value result;
2 std::string image;
3 aip::get_file_content("文件或图片路径", &image);
4 std::string url = "https//www.x.com/sample.jpg"
5
6 // 调用出生证明识别
7 result = client.birth_certificate_v1(image, aip::null);
8 result = client.birth_certificate_v1_url(url, aip::null);
接口详情
可参考API文档:出生证明识别
定额发票识别
SDK 调用示例
1 Json::Value result;
2 std::string image;
3 std::string pdf_file;
4 aip::get_file_content("文件或图片路径", &image);
5 std::string url = "https//www.x.com/sample.jpg"
6 aip::get_file_content("文件或图片路径", &pdf_file);
7
8 // 定额发票识别
9 result = client.quota_invoice_v1(image, aip::null);
10 result = client.quota_invoice_v1_url(url, aip::null);
11 result = client.quota_invoice_v1_pdf(pdf_file, aip::null);
接口详情
可参考API文档:定额发票识别
图文转换器
SDK 调用示例
1 // 图片文件
2 std::string img_file_content;
3 aip::get_file_content("图片文件路径", &img_file_content);
4 // url
5 std::string url = "https//www.x.com/sample.jpg"
6 // pdf文件
7 std::string pdf_file_content;
8 aip::get_file_content("pdf文件路径", &pdf_file_content);
9
10 Json::Value options;
11
12 Json::Value result = ocr->doc_convert_request_v1(img_file_content, options);
13 Json::Value result = ocr->doc_convert_request_v1_url(url.c_str(), options);
14 Json::Value result = ocr->doc_convert_request_v1_pdf(pdf_file_content, options);
15
16 // 获取结果
17 std::string task_id = "任务ID";
18 Json::Value result = ocr->doc_convert_result_v1(task_id);
接口详情
可参考API文档:图文转换器
表格文字识别同步接口
接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别同步接口。
表格文字识别
接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别。