接口说明
通用文字识别
用户向服务请求识别某张图中的所有文字
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用文字识别, 图片参数为本地图片
result = client.general_basic(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别, 图片参数为本地图片
result = client.general_basic(image, options);
Json::Value result;
std::string url = "https//www.x.com/sample.jpg";
// 调用通用文字识别, 图片参数为远程url图片
result = client.general_basic_url(url, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别, 图片参数为远程url图片
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 | 行置信度最小值 |
通用文字识别 返回示例
{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
[
{"words": " TSINGTAO"},
{"words": "青島睥酒"}
]
}
通用文字识别(高精度版)
用户向服务请求识别某张图中的所有文字,相对于通用文字识别该产品精度更高,但是识别耗时会稍长。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用文字识别(高精度版)
result = client.accurate_basic(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(高精度版)
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 | 行置信度最小值 |
通用文字识别(高精度版) 返回示例
参考通用文字识别返回示例
通用文字识别(含位置信息版)
用户向服务请求识别某张图中的所有文字,并返回文字在图中的位置信息。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用文字识别(含位置信息版), 图片参数为本地图片
result = client.general(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["recognize_granularity"] = "big";
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["vertexes_location"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(含位置信息版), 图片参数为本地图片
result = client.general(image, options);
Json::Value result;
std::string url = "https//www.x.com/sample.jpg";
// 调用通用文字识别(含位置信息版), 图片参数为远程url图片
result = client.general_url(url, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["recognize_granularity"] = "big";
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["vertexes_location"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(含位置信息版), 图片参数为远程url图片
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 |
是否返回识别结果中每一行的置信度 |
通用文字识别(含位置信息版) 返回数据参数详情
字段 | 必选 | 类型 | 说明 |
---|---|---|---|
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 | 行置信度最小值 |
通用文字识别(含位置信息版) 返回示例
{
"log_id": 3523983603,
"direction": 0, //detect_direction=true时存在
"words_result_num": 2,
"words_result": [
{
"location": {
"left": 35,
"top": 53,
"width": 193,
"height": 109
},
"words": "感动",
"chars": [ //recognize_granularity=small时存在
{
"location": {
"left": 56,
"top": 65,
"width": 69,
"height": 88
},
"char": "感"
},
{
"location": {
"left": 140,
"top": 65,
"width": 70,
"height": 88
},
"char": "动"
}
]
}
...
]
}
通用文字识别(含位置高精度版)
用户向服务请求识别某张图中的所有文字,并返回文字在图片中的坐标信息,相对于通用文字识别(含位置信息版)该产品精度更高,但是识别耗时会稍长。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用文字识别(含位置高精度版)
result = client.accurate(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["recognize_granularity"] = "big";
options["detect_direction"] = "true";
options["vertexes_location"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(含位置高精度版)
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 | 行置信度最小值 |
通用文字识别(含位置高精度版) 返回示例
{
"log_id": 3523983603,
"direction": 0, //detect_direction=true时存在
"words_result_num": 2,
"words_result": [
{
"location": {
"left": 35,
"top": 53,
"width": 193,
"height": 109
},
"words": "感动",
"chars": [ //recognize_granularity=small时存在
{
"location": {
"left": 56,
"top": 65,
"width": 69,
"height": 88
},
"char": "感"
},
{
"location": {
"left": 140,
"top": 65,
"width": 70,
"height": 88
},
"char": "动"
}
]
}
...
]
}
通用文字识别(含生僻字版)
某些场景中,图片中的中文不光有常用字,还包含了生僻字,这时用户需要对该图进行文字识别,应使用通用文字识别(含生僻字版)。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用文字识别(含生僻字版), 图片参数为本地图片
result = client.general_enhanced(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(含生僻字版), 图片参数为本地图片
result = client.general_enhanced(image, options);
Json::Value result;
std::string url = "https//www.x.com/sample.jpg";
// 调用通用文字识别(含生僻字版), 图片参数为远程url图片
result = client.general_enhanced_url(url, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["language_type"] = "CHN_ENG";
options["detect_direction"] = "true";
options["detect_language"] = "true";
options["probability"] = "true";
// 带参数调用通用文字识别(含生僻字版), 图片参数为远程url图片
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 | 行置信度最小值 |
通用文字识别(含生僻字版) 返回示例
{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
[
{"words": " TSINGTAO"},
{"words": "青島睥酒"}
]
}
网络图片文字识别
用户向服务请求识别一些网络上背景复杂,特殊字体的文字。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用网络图片文字识别, 图片参数为本地图片
result = client.web_image(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
options["detect_language"] = "true";
// 带参数调用网络图片文字识别, 图片参数为本地图片
result = client.web_image(image, options);
Json::Value result;
std::string url = "https//www.x.com/sample.jpg";
// 调用网络图片文字识别, 图片参数为远程url图片
result = client.web_image_url(url, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
options["detect_language"] = "true";
// 带参数调用网络图片文字识别, 图片参数为远程url图片
result = client.web_image_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 | 行置信度最小值 |
网络图片文字识别 返回示例
{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
[
{"words": " TSINGTAO"},
{"words": "青島睥酒"}
]
}
身份证识别
用户向服务请求识别身份证,身份证识别包括正面和背面。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
std::string id_card_side = "back";
// 调用身份证识别
result = client.idcard(image, id_card_side, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
options["detect_risk"] = "false";
// 带参数调用身份证识别
result = client.idcard(image, id_card_side, options);
身份证识别 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 | ||
id_card_side | 是 | std::string | front - 身份证含照片的一面 back - 身份证带国徽的一面 |
front:身份证含照片的一面;back:身份证带国徽的一面 | |
detect_direction | 否 | std::string | true false |
false | 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向。 |
detect_risk | 否 | std::string | true - 开启 false - 不开启 |
是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。可选值:true-开启;false-不开启 |
身份证识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
direction | 否 | number | 图像方向,当detect_direction=true时存在。 - -1:未定义, - 0:正向, - 1: 逆时针90度, - 2:逆时针180度, - 3:逆时针270度 |
image_status | 是 | string | normal-识别正常 reversed_side-未摆正身份证 non_idcard-上传的图片中不包含身份证 blurred-身份证模糊 over_exposure-身份证关键字段反光或过曝 unknown-未知状态 |
risk_type | 否 | string | 输入参数 detect_risk = true 时,则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknow-其他未知情况 |
edit_tool | 否 | string | 如果参数 detect_risk = true 时,则返回此字段。如果检测身份证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值无此参数 |
log_id | 是 | number | 唯一的log id,用于问题定位 |
words_result | 是 | array(object) | 定位和识别结果数组 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
+location | 是 | array(object) | 位置数组(坐标0点为左上角) |
++left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
++top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
++width | 是 | number | 表示定位位置的长方形的宽度 |
++height | 是 | number | 表示定位位置的长方形的高度 |
+words | 否 | string | 识别结果字符串 |
身份证识别 返回示例
{
"log_id": 2648325511,
"direction": 0,
"image_status": "normal",
"idcard_type": "normal",
"edit_tool": "Adobe Photoshop CS3 Windows",
"words_result": {
"住址": {
"location": {
"left": 267,
"top": 453,
"width": 459,
"height": 99
},
"words": "南京市江宁区弘景大道3889号"
},
"公民身份号码": {
"location": {
"left": 443,
"top": 681,
"width": 589,
"height": 45
},
"words": "330881199904173914"
},
"出生": {
"location": {
"left": 270,
"top": 355,
"width": 357,
"height": 45
},
"words": "19990417"
},
"姓名": {
"location": {
"left": 267,
"top": 176,
"width": 152,
"height": 50
},
"words": "伍云龙"
},
"性别": {
"location": {
"left": 269,
"top": 262,
"width": 33,
"height": 52
},
"words": "男"
},
"民族": {
"location": {
"left": 492,
"top": 279,
"width": 30,
"height": 37
},
"words": "汉"
}
},
"words_result_num": 6
}
银行卡识别
识别银行卡并返回卡号和发卡行。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用银行卡识别
result = 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: 信用卡 |
银行卡识别 返回示例
{
"log_id": 1447188951,
"result": {
"bank_card_number": "622500000000000",
"bank_name": "招商银行",
"bank_card_type": 1
}
}
驾驶证识别
对机动车驾驶证所有关键字段进行识别
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用驾驶证识别
result = client.driving_license(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
// 带参数调用驾驶证识别
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 | 识别结果字符串 |
驾驶证识别 返回示例
{
"errno": 0,
"msg": "success",
"data": {
"words_result_num": 10,
"words_result": {
"证号": {
"words": "3208231999053090"
},
"有效期限": {
"words": "6年"
},
"准驾车型": {
"words": "B2"
},
"有效起始日期": {
"words": "20101125"
},
"住址": {
"words": "江苏省南通市海门镇秀山新城"
},
"姓名": {
"words": "小欧欧"
},
"国籍": {
"words": "中国"
},
"出生日期": {
"words": "19990530"
},
"性别": {
"words": "男"
},
"初次领证日期": {
"words": "20100125"
}
}
}
}
行驶证识别
对机动车行驶证所有关键字段进行识别
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用行驶证识别
result = client.vehicle_license(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["detect_direction"] = "true";
options["accuracy"] = "normal";
// 带参数调用行驶证识别
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 | 识别结果字符串 |
行驶证识别 返回示例
{
"errno": 0,
"msg": "success",
"data": {
"words_result_num": 10,
"words_result": {
"品牌型号": {
"words": "保时捷GT37182RUCRE"
},
"发证日期": {
"words": "20160104"
},
"使用性质": {
"words": "非营运"
},
"发动机号码": {
"words": "20832"
},
"号牌号码": {
"words": "苏A001"
},
"所有人": {
"words": "圆圆"
},
"住址": {
"words": "南京市江宁区弘景大道"
},
"注册日期": {
"words": "20160104"
},
"车辆识别代号": {
"words": "HCE58"
},
"车辆类型": {
"words": "小型轿车"
}
}
}
}
车牌识别
识别机动车车牌,并返回签发地和号牌。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用车牌识别
result = client.license_plate(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["multi_detect"] = "true";
// 带参数调用车牌识别
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 | 是 | 车牌号码 |
车牌识别 返回示例
{
"log_id": 3583925545,
"words_result": {
"color": "blue",
"number": "苏HS7766"
}
}
营业执照识别
识别营业执照,并返回关键字段的值,包括单位名称、法人、地址、有效期、证件编号、社会信用代码等。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用营业执照识别
result = client.business_license(image, aip::null);
营业执照识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
营业执照识别 返回数据参数详情
参数 | 是否必须 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | number | 请求标识码,随机数,唯一。 |
words_result_num | 是 | number | 识别结果数,表示words_result的元素个数 |
words_result | 是 | array(object) | 识别结果数组 |
left | 是 | number | 表示定位位置的长方形左上顶点的水平坐标 |
top | 是 | number | 表示定位位置的长方形左上顶点的垂直坐标 |
width | 是 | number | 表示定位位置的长方形的宽度 |
height | 是 | number | 表示定位位置的长方形的高度 |
words | 否 | string | 识别结果字符串 |
营业执照识别 返回示例
{
"log_id": 490058765,
"words_result": {
"单位名称": {
"location": {
"left": 500,
"top": 479,
"width": 618,
"height": 54
},
"words": "袁氏财团有限公司"
},
"法人": {
"location": {
"left": 938,
"top": 557,
"width": 94,
"height": 46
},
"words": "袁运筹"
},
"地址": {
"location": {
"left": 503,
"top": 644,
"width": 574,
"height": 57
},
"words": "江苏省南京市中山东路19号"
},
"有效期": {
"location": {
"left": 779,
"top": 1108,
"width": 271,
"height": 49
},
"words": "2015年02月12日"
},
"证件编号": {
"location": {
"left": 1219,
"top": 357,
"width": 466,
"height": 39
},
"words": "苏餐证字(2019)第666602666661号"
},
"社会信用代码": {
"location": {
"left": 0,
"top": 0,
"width": 0,
"height": 0
},
"words": "无"
}
},
"words_result_num": 6
}
通用票据识别
用户向服务请求识别医疗票据、发票、的士票、保险保单等票据类图片中的所有文字,并返回文字在图中的位置信息。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用票据识别
result = client.receipt(image, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["recognize_granularity"] = "big";
options["probability"] = "true";
options["accuracy"] = "normal";
options["detect_direction"] = "true";
// 带参数调用通用票据识别
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:行置信度最小值 |
通用票据识别 返回示例
{
"log_id": 2661573626,
"words_result": [
{
"location": {
"left": 10,
"top": 3,
"width": 121,
"height": 24
},
"words": "姓名:小明明",
"chars": [
{
"location": {
"left": 16,
"top": 6,
"width": 17,
"height": 20
},
"char": "姓"
}
...
]
},
{
"location": {
"left": 212,
"top": 3,
"width": 738,
"height": 24
},
"words": "卡号/病案号:105353990标本编号:150139071送检科室:血液透析门诊病房",
"chars": [
{
"location": {
"left": 218,
"top": 6,
"width": 18,
"height": 21
},
"char": "卡"
}
...
]
}
],
"words_result_num": 2
}
自定义模板文字识别
自定义模板文字识别,是针对百度官方没有推出相应的模板,但是当用户需要对某一类卡证/票据(如房产证、军官证、火车票等)进行结构化的提取内容时,可以使用该产品快速制作模板,进行识别。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
std::string templateSign = "Nsdax2424asaAS791823112";
// 调用自定义模板文字识别
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 | 识别返回的结果 |
自定义模板文字识别 返回示例
{
"isStructured": true,
"ret": [
{
"charset": [
{
"rect": {
"top": 183,
"left": 72,
"width": 14,
"height": 28
},
"word": "5"
},
{
"rect": {
"top": 183,
"left": 90,
"width": 14,
"height": 28
},
"word": "4"
},
{
"rect": {
"top": 183,
"left": 103,
"width": 15,
"height": 28
},
"word": "."
},
{
"rect": {
"top": 183,
"left": 116,
"width": 14,
"height": 28
},
"word": "5"
},
{
"rect": {
"top": 183,
"left": 133,
"width": 19,
"height": 28
},
"word": "元"
}
],
"word_name": "票价",
"word": "54.5元"
},
{
"charset": [
{
"rect": {
"top": 144,
"left": 35,
"width": 14,
"height": 28
},
"word": "2"
},
{
"rect": {
"top": 144,
"left": 53,
"width": 14,
"height": 28
},
"word": "0"
},
{
"rect": {
"top": 144,
"left": 79,
"width": 14,
"height": 28
},
"word": "1"
},
{
"rect": {
"top": 144,
"left": 97,
"width": 14,
"height": 28
},
"word": "7"
}
]
]
}
表格文字识别同步接口
自动识别表格线及表格内容,结构化输出表头、表尾及每个单元格的文字内容。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用表格文字识别同步接口
result = client.form(image, aip::null);
表格文字识别同步接口 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
表格文字识别同步接口 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | long | 唯一的log id,用于问题定位 |
forms_result_num | 是 | number | |
forms_result | 是 | array(object) | 识别结果 |
表格文字识别同步接口 返回示例
{
"log_id": 3445697108,
"forms_result_num": 1,
"forms_result": [
{
"body": [
{
"column": 0,
"probability": 0.99855202436447,
"row": 0,
"vertexes_location": [
{
"x": -2,
"y": 260
},
{
"x": 21,
"y": 244
},
{
"x": 35,
"y": 266
},
{
"x": 12,
"y": 282
}
],
"words": "目"
},
{
"column": 3,
"probability": 0.99960500001907,
"row": 5,
"vertexes_location": [
{
"x": 603,
"y": 52
},
{
"x": 634,
"y": 32
},
{
"x": 646,
"y": 50
},
{
"x": 615,
"y": 71
}
],
"words": "66"
},
{
"column": 3,
"probability": 0.99756097793579,
"row": 6,
"vertexes_location": [
{
"x": 634,
"y": 73
},
{
"x": 648,
"y": 63
},
{
"x": 657,
"y": 77
},
{
"x": 643,
"y": 86
}
],
"words": "4"
},
{
"column": 3,
"probability": 0.96489900350571,
"row": 10,
"vertexes_location": [
{
"x": 699,
"y": 178
},
{
"x": 717,
"y": 167
},
{
"x": 727,
"y": 183
},
{
"x": 710,
"y": 194
}
],
"words": "3,"
},
{
"column": 3,
"probability": 0.99809801578522,
"row": 14,
"vertexes_location": [
{
"x": 751,
"y": 296
},
{
"x": 786,
"y": 273
},
{
"x": 797,
"y": 289
},
{
"x": 761,
"y": 312
}
],
"words": "206"
}
],
"footer": [
{
"column": 0,
"probability": 0.99853301048279,
"row": 0,
"vertexes_location": [
{
"x": 605,
"y": 698
},
{
"x": 632,
"y": 680
},
{
"x": 643,
"y": 696
},
{
"x": 616,
"y": 714
}
],
"words": "22"
}
],
"header": [
{
"column": 0,
"probability": 0.94802802801132,
"row": 0,
"vertexes_location": [
{
"x": 183,
"y": 96
},
{
"x": 286,
"y": 29
},
{
"x": 301,
"y": 52
},
{
"x": 199,
"y": 120
}
],
"words": "29月"
}
],
"vertexes_location": [
{
"x": -154,
"y": 286
},
{
"x": 512,
"y": -153
},
{
"x": 953,
"y": 513
},
{
"x": 286,
"y": 953
}
]
}
]
}
表格文字识别
自动识别表格线及表格内容,结构化输出表头、表尾及每个单元格的文字内容。表格文字识别接口为异步接口,分为两个API:提交请求接口、获取结果接口。
Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用表格文字识别
result = client.table_recognize(image, aip::null);
表格文字识别 请求参数详情
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | std::string | 图片数据的二进制字符串,可以使用aip::get_file_content函数获取 |
表格文字识别 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | long | 唯一的log id,用于问题定位 |
result | 是 | list | 返回的结果列表 |
+request_id | 是 | string | 该请求生成的request_id,后续使用该request_id获取识别结果 |
表格文字识别 返回示例
{
"result" : [
{
"request_id" : "1234_6789"
}
],
"log_id":149689853984104
}
失败应答示例(详细的错误码说明见本文档底部):
{
"log_id": 149319909347709,
"error_code": 282000
"error_msg":"internal error"
}
表格识别结果
获取表格文字识别结果
Json::Value result;
std::string request_id = "23454320-23255";
// 调用表格识别结果
result = client.table_result_get(request_id, aip::null);
// 如果有可选参数
std::map<std::string, std::string> options;
options["result_type"] = "json";
// 带参数调用表格识别结果
result = client.table_result_get(request_id, options);
表格识别结果 请求参数详情
参数名称 | 是否必选 | 类型 | 可选值范围 | 默认值 | 说明 |
---|---|---|---|---|---|
request_id | 是 | std::string | 发送表格文字识别请求时返回的request id | ||
result_type | 否 | std::string | json excel |
excel | 期望获取结果的类型,取值为“excel”时返回xls文件的地址,取值为“json”时返回json格式的字符串,默认为”excel” |
表格识别结果 返回数据参数详情
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | long | 唯一的log id,用于问题定位 |
result | 是 | object | 返回的结果 |
+result_data | 是 | string | 识别结果字符串,如果request_type是excel,则返回excel的文件下载地址,如果request_type是json,则返回json格式的字符串 |
+percent | 是 | int | 表格识别进度(百分比) |
+request_id | 是 | string | 该图片对应请求的request_id |
+ret_code | 是 | int | 识别状态,1:任务未开始,2:进行中,3:已完成 |
+ret_msg | 是 | string | 识别状态信息,任务未开始,进行中,已完成 |
表格识别结果 返回示例
成功应答示例:
{
"result" : {
"result_data" : "",
"persent":100,
"request_id": "149691317905102",
"ret_code": 3
"ret_msg": "已完成",
},
"log_id":149689853984104
}
当request_type为excel时,result_data格式样例为:
{
"file_url":"https://ai.baidu.com/file/xxxfffddd"
}
当request_type为json时,result_data格式样例为:
{
"form_num": 1,
"forms": [
{
"header": [
{
"row": [
1
],
"column": [
1,
2
],
"word": "表头信息1",
}
],
"footer": [
{
"row": [
1
],
"column": [
1,
2
],
"word": "表尾信息1",
}
],
"body": [
{
"row": [
1
],
"column": [
1,
2
],
"word": "单元格文字",
}
]
}
]
}
其中各个参数的说明(json方式返回结果时):
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
form_num | 是 | int | 表格数量(可能一张图片中包含多个表格) |
forms | 是 | list | 表格内容信息的列表 |
+header | 是 | list | 每个表格中,表头数据的相关信息 |
+footer | 是 | list | 表尾的相关信息 |
+body | 是 | list | 表格主体部分的数据 |
++row | 是 | list | 该单元格占据的行号 |
++column | 是 | list | 该单元格占据的列号 |
++word | 是 | string | 该单元格中的文字信息 |
失败应答示例(详细的错误码说明见本文档底部):
{
"log_id": 149319909347709,
"error_code": 282000
"error_msg":"internal error"
}
增值税发票识别
#include "ocr.h"
// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";
aip::Ocr client(app_id, api_key, secret_key);
Json::Value result;
// 如果有可选参数
std::map<std::string, std::string> options;
std::string image;
//图片识别
aip::get_file_content("./sample.jpg", &image);
result = client.vatInvoice(image, options);
//url识别
result = client.vatInvoiceUrl("htpp://test.jpg", options);
//pdf识别
aip::get_file_content("./pdf.jpg", &image);
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 | 备注 |
返回示例
{
"log_id": "5425496231209218858",
"words_result_num": 29,
"words_result": {
"InvoiceNum": "14641426",
"SellerName": "上海易火广告传媒有限公司",
"CommodityTaxRate": [
{
"word": "6%",
"row": "1"
}
],
"SellerBank": "中国银行南翔支行446863841354",
"Checker": ":沈园园",
"TotalAmount": "94339.62",
"CommodityAmount": [
{
"word": "94339.62",
"row": "1"
}
],
"InvoiceDate": "2016年06月02日",
"CommodityTax": [
{
"word": "5660.38",
"row": "1"
}
],
"PurchaserName": "百度时代网络技术(北京)有限公司",
"CommodityNum": [
{
"word": "",
"row": "1"
}
],
"Province": "上海",
"City": "",
"SheetNum": "第三联",
"Agent": "否",
"PurchaserBank": "招商银行北京分行大屯路支行8661820285100030",
"Remarks": "告传",
"Password": "074/45781873408>/6>8>65*887676033/51+<5415>9/32--852>1+29<65>641-5>66<500>87/*-34<943359034>716905113*4242>",
"SellerAddress": ":嘉定区胜辛南路500号15幢1161室55033753",
"PurchaserAddress": "北京市海淀区东北旺西路8号中关村软件园17号楼二属A2010-59108001",
"InvoiceCode": "3100153130",
"CommodityUnit": [
{
"word": "",
"row": "1"
}
],
"Payee": ":徐蓉",
"PurchaserRegisterNum": "110108787751579",
"CommodityPrice": [
{
"word": "",
"row": "1"
}
],
"NoteDrawer": "沈园园",
"AmountInWords": "壹拾万圆整",
"AmountInFiguers": "100000.00",
"TotalTax": "5660.38",
"InvoiceType": "专用发票",
"SellerRegisterNum": "913101140659591751",
"CommodityName": [
{
"word": "信息服务费",
"row": "1"
}
],
"CommodityType": [
{
"word": "",
"row": "1"
}
]
}
}
出租车票识别
#include "ocr.h"
// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";
aip::Ocr client(app_id, api_key, secret_key);
Json::Value result;
// 如果有可选参数
std::map<std::string, std::string> options;
std::string image;
//图片识别
aip::get_file_content("./sample.jpg", &image);
result = client.taxiReceipt(image, options);
//url识别
result = client.taxiReceiptUrl("htpp://test.jpg", options);
**请求参数详情**
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
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 | 是 | 里程 |
返回示例
{
"log_id":2034039896,
"words_result_num":6,
"words_result":
{
"Date":"2017-11-26",
"Fare":"¥153.30元",
"InvoiceCode":"111001681009",
"InvoiceNum":"90769610",
"TaxiNum":"BV2062",
"Time":"20:42-21:07",
"FuelOilSurcharge": "¥0.00",
"CallServiceSurcharge": "¥0.00",
"Province": "浙江省",
"City": "杭州市",
"PricePerkm": "2.50元/KM",
"Distance": "4.5KM"
}
}
VIN码识别
#include "ocr.h"
// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";
aip::Ocr client(app_id, api_key, secret_key);
Json::Value result;
// 如果有可选参数
std::map<std::string, std::string> options;
std::string image;
//图片识别
aip::get_file_content("./sample.jpg", &image);
result = client.vinCode(image, options);
//url识别
result = client.vinCodeUrl("htpp://test.jpg", options);
**请求参数详情**
参数名称 | 是否必选 | 类型 | 说明 |
---|---|---|---|
image | 是 | mixed | 本地图片路径或者图片二进制数据或url |
返回参数
字段 | 是否必选 | 类型 | 说明 |
---|---|---|---|
log_id | 是 | uint64 | 唯一的log id,用于问题定位 |
words_result | 是 | array[] | 定位和识别结果数组 |
location | 是 | object{} | 识别结果 |
words | 是 | string | VIN码识别结果 |
words_result_num | 是 | int | 识别结果数,表示words_result的元素个数 |
返回示例
{
"log_id": 246589877,
"words_result": [
{
"location": {
"left": 124,
"top": 11,
"width": 58,
"height": 359
},
"words": "LFV2A11K8D4010942"
}
],
"words_result_num": 1
}
火车票识别
#include "ocr.h"
// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";
aip::Ocr client(app_id, api_key, secret_key);
Json::Value result;
// 如果有可选参数
std::map<std::string, std::string> options;
std::string image;
//图片识别
aip::get_file_content("./sample.jpg", &image);
result = client.trainTicket(image, options);
//url识别
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 | 是 | 座位号 |
返回示例
{
"log_id": "12317512659",
"direction": 1,
"words_result_num": 13,
"words_result": {
"id_num": "2302051998****156X",
"name": "裴一丽",
"ticket_rates": "¥54.5元",
"destination_station": "天津站",
"seat_category": "二等座",
"sales_station": "北京南",
"ticket_num": "F05706",
"seat_num": "02车03C号",
"time": "09:36",
"date": "2019年04月03日",
"serial_number": "10010300067846",
"train_num": "C255",
"starting_station": "北京南站"
}
}
数字识别
#include "ocr.h"
// 设置APPID/AK/SK
std::string app_id = "你的 App ID";
std::string api_key = "你的 Api key";
std::string secret_key = "你的 Secret Key";
aip::Ocr client(app_id, api_key, secret_key);
Json::Value result;
// 如果有可选参数
std::map<std::string, std::string> options;
std::string image;
//图片识别
aip::get_file_content("./sample.jpg", &image);
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 | 单字符识别结果 |
返回示例
{
"log_id": 620759800,
"words_result": [
{
"location": {
"left": 56,
"top": 0,
"width": 21,
"height": 210
},
"words": "3"
}
],
"words_result_num": 1
}