资讯 社区 文档
技术能力
语音技术
文字识别
人脸与人体
图像技术
语言与知识
视频技术

接口说明

通用文字识别

用户向服务请求识别某张图中的所有文字

    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 行置信度最小值

通用文字识别(高精度版) 返回示例

{
    "log_id": 1390582998516105216,
    "words_result_num": 2
    "words_result": [
        {
            "words": " OCR"
        },
        {
            "words": "百度通用文字识别高精度版"
        }
    ]  
}

通用文字识别(含位置信息版)

用户向服务请求识别某张图中的所有文字,并返回文字在图中的位置信息。

    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
是否返回识别结果中每一行的置信度
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 行置信度最小值

通用文字识别(含位置信息版) 返回示例

{
"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.webimage(image, aip::null);

   // 如果有可选参数
   std::map<std::string, std::string> options;
   options["detect_direction"] = "true";
   options["detect_language"] = "true";

   // 带参数调用网络图片文字识别, 图片参数为本地图片
   result = client.webimage(image, options);

   Json::Value result;

   std::string url = "https//www.x.com/sample.jpg";

   // 调用网络图片文字识别, 图片参数为远程url图片
   result = client.webimage_url(url, aip::null);

   // 如果有可选参数
   std::map<std::string, std::string> options;
   options["detect_direction"] = "true";
   options["detect_language"] = "true";

   // 带参数调用网络图片文字识别, 图片参数为远程url图片
   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 行置信度最小值

网络图片文字识别 返回示例

{
"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 和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 识别结果字符串

身份证识别 返回示例

{
    "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函数获取
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 识别结果字符串

营业执照识别 返回示例

{
    "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"
                }
            ]
    ]
}

增值税发票识别

支持对增值税普票、专票、卷票、电子发票、区块链发票的所有字段进行结构化识别,包括发票基本信息、销售方及购买方信息、商品信息、价税信息等,其中五要素字段的识别准确率超过 99.9%; 同时,支持对增值税卷票的 21 个关键字段进行识别,包括发票类型、发票代码、发票号码、机打号码、机器编号、收款人、销售方名称、销售方纳税人识别号、开票日期、购买方名称、购买方纳税人识别号、项目、单价、数量、金额、税额、合计金额(小写)、合计金额(大写)、校验码、省、市,四要素字段的识别准确率可达95%。

     #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"
			}
		]
	}
}

出租车票识别

支持识别全国各大城市出租车票的 16 个关键字段,包括发票号码、代码、车号、日期、总金额、燃油附加费、叫车服务费、省、市、单价、里程、上车时间、下车时间等。

     #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
}

火车票识别

支持对红、蓝火车票的13个关键字段进行结构化识别,包括车票号码、始发站、目的站、车次、日期、票价、席别、姓名、座位号、身份证号、售站、序列号、时间。

     #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": "北京南站"
	}
}

数字识别

对图片中的数字进行提取和识别,自动过滤非数字内容,仅返回数字内容及其位置信息,识别准确率超过99%。

     #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
}

印章识别

检测并识别合同文件或常用票据中的印章,输出文字内容、印章位置信息以及相关置信度,已支持圆形章、椭圆形章、方形章等常见印章检测与识别

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 印章识别
    	result = client.seal(image,aip::null);
    

请求参数详情

参数 是否必选 类型 可选值范围 说明
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 其他字段识别内容的置信度

返回示例

{
	"result": [
		{
			"major": {
				"probability": 0.99759155511856,
				"words": "峨眉山旅游股份有限公司成都峨眉山雪芽大酒店分公司"
			},
			"minor": [
				{
					"probability": 0.99994027614594,
					"words": "前厅部"
				}
			],
			"probability": 0.9936261177063,
			"location": {
				"top": 594,
				"left": 918,
				"width": 150,
				"height": 142
			},
			"type": "circle"
		}
	],
	"log_id": "1349006147834609664",
	"result_num": 1
}

网络图片文字识别(含位置版)

支持识别艺术字体或背景复杂的文字内容,除文字信息外,还可返回每行文字的位置信息、行置信度,以及单字符内容和位置等。

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 网络图片文字识别(含位置版)
    	result = client.webimageloc(image,aip::null);
    	// 文件url
    	std::string = "http://host/test.jpeg"
    	result = client.webimagelocurl(url,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用网络图片文字识别(含位置版)
    	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 表示定位定位位置的长方形的高度

返回示例

{
    "log_id": 1390656223866519552,
    "words_result_num": 3,
    "words_result": [
        {
            "words": "梦想起航",
            "location": {
                "top": 328,
                "left": 1079,
                "width": 56,
                "height": 262
            },
        },
        {
            "words": "前往下一个目的地",
            "location": {
                "top": 329,
                "left": 1160,
                "width": 63,
                "height": 446
            },
        },
        {
            "words": "开始新的旅程",
            "location": {
                "top": 455,
                "left": 1246,
                "width": 63,
                "height": 340
            },
        }
    ],
}

仪器仪表盘读数识别

适用于不同品牌、不同型号的仪器仪表盘读数识别,广泛适用于各类血糖仪、血压仪、燃气表、电表等,可识别表盘上的数字、英文、符号,支持液晶屏、字轮表等表型。

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 仪器仪表盘读数识别
    	result = client.meter(image,aip::null);
    	// 文件url
    	std::string = "http://host/test.jpeg"
    	result = client.meterurl(url,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用仪器仪表盘读数识别
    	result = client.meter(image, options);
    

请求参数详情

参数 是否必选 类型 可选值范围 说明
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个点坐标信息

返回示例

{
    "log_id": "1392680790663364608",
	"words_result_num": 5
	"words_result": [
		{
			"words": "5.8",
			"location": {
				"top": 150,
				"left": 370,
				"width": 87,
				"height": 79
			}
		},
		{
			"words": "mmol/L",
			"location": {
				"top": 241,
				"left": 402,
				"width": 52,
				"height": 12
			}
		},
		{
			"words": "10:38",
			"location": {
				"top": 115,
				"left": 347,
				"width": 42,
				"height": 21
			}
		},
		{
			"words": "12-11",
			"location": {
				"top": 116,
				"left": 410,
				"width": 36,
				"height": 20
			}
		},
		{
			"words": "am",
			"location": {
				"top": 115,
				"left": 391,
				"width": 12,
				"height": 5
			}
		}
	],
}

试卷分析与识别

可对文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 试卷分析与识别
    	result = client.docanalysis(image,aip::null);
    	// 文件url
    	std::string = "http://host/test.jpeg"
    	result = client.docanalysisurl(url,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用试卷分析与识别
    	result = client.docanalysis(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条展示)

返回示例

{
	"results_num": 6,
	"log_id": "4488766695474114139",
	"img_direction": 0,
	"layouts_num": 0,
	"results": [
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 124,
					"left": 136,
					"width": 418,
					"height": 65
				},
				"word": "五默写(4分)"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 246,
					"left": 136,
					"width": 37,
					"height": 45
				},
				"word": "1"
			},
		},
		{
			"words_type": "handwriting",
			"words": {
				"words_location": {
					"top": 195,
					"left": 237,
					"width": 469,
					"height": 104
				},
				"word": "采菊东篱下"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 241,
					"left": 889,
					"width": 287,
					"height": 52
				},
				"word": "悠然见南山?"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 415,
					"left": 134,
					"width": 472,
					"height": 52
				},
				"word": "2.商女不知亡国恨"
			},
		},
		{
			"words_type": "handwriting",
			"words": {
				"words_location": {
					"top": 377,
					"left": 607,
					"width": 556,
					"height": 93
				},
				"word": "隔江犹唱后庭花。"
			},
		},
	]
}

手写文字识别

支持对图片中的手写中文、手写数字进行检测和识别,针对不规则的手写字体进行专项优化,识别准确率可达90%以上。

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 手写文字识别
    	result = client.handwriting(image,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用手写文字识别
    	result = client.handwriting(image, options);
    

请求参数详情

参数 是否必选 类型 可选值范围 说明
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度

返回示例

    {
        "log_id": 620759800,
        "words_result": [
            {
                "location": {
                    "left": 56,
                    "top": 0,
                    "width": 21,
                    "height": 210
                },
                "words": "3"
            }
        ],
        "words_result_num": 1
    }

办公文档识别

可对办公类文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景。

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 办公文档识别
    	result = client.docanalysisoffice(image,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用办公文档识别
    	result = client.docanalysisoffice(image, options);
    

请求参数详情

参数 是否必选 类型 可选值范围 说明
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条展示)

返回示例

{
	"results_num": 5,
	"log_id": "1410491260247950412",
	"results": [
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 88,
					"left": 442,
					"width": 142,
					"height": 49
				},
				"word": "行程单"
			}
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 241,
					"left": 439,
					"width": 393,
					"height": 37
				},
				"word": "美国东海岸名校8天7晚"
			}
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 318,
					"left": 436,
					"width": 774,
					"height": 31
				},
				"word": "国会大厦位于华盛顿25米高的国会山上,是美国的心脏建筑。"
			}
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 374,
					"left": 434,
					"width": 805,
					"height": 31
				},
				"word": "中央顶楼上的大圆顶上立有一尊6米高的自由女神青铜雕像。"
			}
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 431,
					"left": 436,
					"width": 556,
					"height": 31
				},
				"word": "东面的大草坪是历届总统举行就职典礼的地方。"
			}
		}
	]
}

二维码识别

对图片中的二维码、条形码进行检测和识别,返回存储的文字信息

    	Json::Value result;;
    	std::string image;
    	aip::get_file_content("/assets/sample.jpg", &image);
    	// 二维码识别
    	result = client.qrcode(image,aip::null);
    	// 如果有可选参数
    	std::map<std::string, std::string> options;
    	// 带参数调用二维码识别
    	result = client.qrcode(image, options);
    

请求参数详情

参数 是否必选 类型 可选值范围 说明
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 条形码识别内容,暂时只限于识别中英文结果

返回示例

{
    "log_id": 863402790,
    "codes_result": [
        {
            "type": "QR_CODE",
            "text": [
                "中国",
                "北京"
            ]
        }
    ],
    "codes_result_num": 1
}
示例2(多个图的情况):
{
    "log_id": 1508509437,
    "codes_result": [
        {
            "type": "QR_CODE",
            "text": [
                "HTTP://Q8R.HK/YELZ0"
            ]
        },
        {
            "type": "PDF_417",
            "text": [
                "PDF417偼丄TL-30偱撉傒庢傝壜擻偱偡丅"
            ]
        },
        {
            "type": "CODABAR",
            "text": [
                "000800"
            ]
        },
        {
            "type": "CODE_39",
            "text": [
                "1234567890"
            ]
        },
        {
            "type": "AZTEC",
            "text": [
                "www.tec-it.com"
            ]
        },
        {
            "type": "DATA_MATRIX",
            "text": [
                "Wikipedia, the free encyclopedia"
            ]
        },
        {
            "type": "CODE_93",
            "text": [
                "123456789"
            ]
        },
        {
            "type": "CODE_128",
            "text": [
                "50090500019191"
            ]
        },
        {
            "type": "EAN_8",
            "text": [
                "12345670"
            ]
        },
        {
            "type": "EAN_13",
            "text": [
                "6901234567892"
            ]
        },
        {
            "type": "UPC_E",
            "text": [
                "01234565"
            ]
        }
    ],
    "codes_result_num": 11
}

试卷分析与识别

可对文档版面进行分析,输出图、表、标题、文本的位置,并输出分版块内容的OCR识别结果,支持中、英两种语言,手写、印刷体混排多种场景

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用试卷分析与识别
result = client.docAnalysis(image, aip::null);
std::string url = 
result = client.docAnalysisUrl(url, aip::null);
//  如果有可选参数
std::map<std::string, std::string> options;
options["multi_detect"] = ""
result = client.docAnalysis(image, options);
result = 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条展示)

返回示例

{
	"results_num": 6,
	"log_id": "4488766695474114139",
	"img_direction": 0,
	"layouts_num": 0,
	"results": [
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 124,
					"left": 136,
					"width": 418,
					"height": 65
				},
				"word": "五默写(4分)"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 246,
					"left": 136,
					"width": 37,
					"height": 45
				},
				"word": "1"
			},
		},
		{
			"words_type": "handwriting",
			"words": {
				"words_location": {
					"top": 195,
					"left": 237,
					"width": 469,
					"height": 104
				},
				"word": "采菊东篱下"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 241,
					"left": 889,
					"width": 287,
					"height": 52
				},
				"word": "悠然见南山?"
			},
		},
		{
			"words_type": "print",
			"words": {
				"words_location": {
					"top": 415,
					"left": 134,
					"width": 472,
					"height": 52
				},
				"word": "2.商女不知亡国恨"
			},
		},
		{
			"words_type": "handwriting",
			"words": {
				"words_location": {
					"top": 377,
					"left": 607,
					"width": 556,
					"height": 93
				},
				"word": "隔江犹唱后庭花。"
			},
		},
	]
}

机动车销售发票

支持对机动车销售发票的26个关键字段进行结构化识别,包括发票代码、发票号码、开票日期、机器编号、购买方名称、购买方身份证号码/组织机构代码、车辆类型、厂牌型号、产地、合格证号、发动机号码、车架号码、价税合计、价税合计小写、销货单位名称、电话、纳税人识别号、账号、地址、开户银行、税率、税额、主管税务机关及代码、不含税价格、限乘人数

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用机动车销售发票
result = client.vehicleInvoice(image, aip::null);
std::string url = 
result = 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 限乘人数

返回示例

{
    "log_id": 283449393728149457,
    "words_result_num": 26,
    "words_result": {
        "InvoiceNum": "00875336",
        "Saler": "深圳市新能源汽车销售有限公司",
        "LimitPassenger": "5",
        "MachineCode": "669745967911",
        "VinNum": "LJLGTCRP1J4007581",
        "TaxRate": "16%",
        "PriceTaxLow": "106100.00",
        "InvoiceDate": "2018-11-29",
        "Price": "¥91465.52",
        "SalerBank": "中国工商银行股份有限公司深圳岭园支行",
        "TaxAuthor": "国家锐务总局深圳市龙岗区税务局第五税务所",
        "ManuModel": "江淮牌HFC7007EYBD6",
        "CertificateNum": "WCH0794J0976801",
        "Purchaser": "苏子潇",
        "VehicleType": "纯电动轿车",
        "InvoiceCode": "14975047560",
        "PriceTax": "壹拾万陆仟壹佰圆整",
        "SalerPhone": "0755-83489306",
        "SalerAddress": "深圳市龙岗区龙岗街道百世国际汽车城",
        "Origin": "安徽省合肥市",
        "EngineNum": "18958407",
        "Tax": "14634.48",
        "PurchaserCode": "5135934475603742222",
        "TaxAuthorCode": "14037589413",
        "SalerAccountNum": "中国工商银行股份有限公司深圳岭园支行",
        "SalerCode": "9144928346458292278H"
    }
}

车辆合格证

支持对车辆合格证的23个关键字段进行结构化识别,包括合格证编号、发证日期、车辆制造企业名、车辆品牌、车辆名称、车辆型号、车架号、车身颜色、发动机型号、发动机号、燃料种类、排量、功率、排放标准、轮胎数、轴距、轴数、转向形式、总质量、整备质量、驾驶室准乘人数、最高设计车速、车辆制造日期

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用车辆合格证
result = client.vehicleCertificate(image, aip::null);
std::string url = 
result = client.vehicleCertificateUrl(url, aip::null);
//  如果有可选参数
std::map<std::string, std::string> options;
options["language_type"] = ""
options["result_type"] = ""
options["detect_direction"] = ""
options["line_probability"] = ""
options["words_type"] = ""
result = client.vehicleCertificate(image, options);
result = 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 车辆制造日期

返回示例

{
    "log_id": 14814098736243057,
    "words_result_num": 23,
    "words_result": {
        "ManufactureDate": "2016年10月13日",
        "CarColor": "红",
        "LimitPassenger": "2",
        "EngineType": "WP12.460E50",
        "TotalWeight": "25000",
        "Power": "338",
        "CertificationNo": "WEK29JX98645437",
        "FuelType": "汽油",
        "Manufacturer": "陕西汽车集团有限责任公司",
        "SteeringType": "方向盘",
        "Wheelbase": "3175+1350",
        "SpeedLimit": "105",
        "EngineNo": "1418K129178",
        "SaddleMass": "8600",
        "AxleNum": "3",
        "CarModel": "SX4250MC4",
        "VinNo": "LZGJHYD83JX197344",
        "CarBrand": "陕汽牌",
        "EmissionStandard": "GB17691-2005国V,GB3847-2005",
        "Displacement": "11596",
        "CertificateDate": "2018年11月28日",
        "CarName": "牵引汽车",
        "TyreNum": "10"
    }
}

户口本识别

支持对户口本内常住人口登记卡的全部 22 个字段进行结构化识别,包括户号、姓名、与户主关系、性别、出生地、民族、出生日期、身份证号、本市县其他住址、曾用名、籍贯、宗教信仰、身高、血型、文化程度、婚姻状况、兵役状况、服务处所、职业、何时由何地迁往本市、何时由何地迁往本址、登记日期

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用户口本识别
result = client.householdRegister(image, aip::null);
std::string url = 
result = 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{} 登记日期

返回示例

 {
    "log_id": 1301870459,
    "words_result": {
        "BirthAddress": {
            "words": "河南洛阳市郊区"
        },
        "Birthday": {
            "words": "2016-07-28"
        },
        "CardNo": {
            "words": "410311201607282825"
        },
        "Name": {
            "words": "孙翌晨"
        },
        "Nation": {
            "words": "汉族"
        },
        "Relationship": {
            "words": "户主"
        },
        "Sex": {
            "words": "男"
        },
    },
    "words_result_num": 7
}

飞机行程单识别

支持对飞机行程单的24个字段进行结构化识别,包括电子客票号、印刷序号、姓名、始发站、目的站、航班号、日期、时间、票价、身份证号、承运人、民航发展基金、保险费、燃油附加费、其他税费、合计金额、填开日期、订票渠道、客票级别、座位等级、销售单位号、签注、免费行李、验证码。 同时,支持单张行程单上的多航班信息识别。

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用飞机行程单识别
result = client.airTicket(image, aip::null);
std::string url = 
result = client.airTicketUrl(url, aip::null);
//  如果有可选参数
std::map<std::string, std::string> options;
options["multi_detect"] = ""
result = client.airTicket(image, options);
result = 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 验证码

返回示例

// 识别单航班信息(multi_detect=false,或参数缺省)
{
    "log_id": 7306800033425229106,
    "direction": 0,
    "words_result_num": 18,
    "words_result": {
        "insurance": "20.00",
        "date": "2019-10-22",
        "allow": "20K",
        "flight": "CA6589",
        "issued_by": "中国国际航空服务有限公司",
        "starting_station": "武汉",
        "fare": "260.00",
        "endorsement": "不得签转改期退转",
        "ticket_rates": "350.00",
        "ck": "5866",
        "serial_number": "51523588676",
        "ticket_number": "7843708871196",
        "fuel_surcharge": "EXEMPT",
        "carrier": "南航",
        "issued_date": "2019-10-30",
        "other_tax": "",
        "fare_basis": "NREOW",
        "id_num": "411201123909020877",
        "destination_station": "合肥",
        "name": "郭达",
        "agent_code": "BJS19197300025",
        "time": "21:25",
        "class": "N",
        "dev_fund": "50.00"
    }
}

// 识别多航班信息(multi_detect=true)
{
    "words_result": {
        "insurance": [
            {
                "word": "XXX"
            }
        ],
        "date": [
            {
                "word": "2019-10-18"
            },
            {
                "word": "2019-10-21"
            }
        ],
        "flight": [
            {
                "word": "CZ3565"
            },
            {
                "word": "CZ3566"
            }
        ],
        "issued_by": [
            {
                "word": "上海携程旅行社有限公司"
            }
        ],
        "starting_station": [
            {
                "word": "北京"
            }
        ],
        "fare": [
            {
                "word": "1080.00"
            }
        ],
        "ticket_rates": [
            {
                "word": "1420.00"
            }
        ],
        "serial_number": [
            {
                "word": "45956029770"
            }
        ],
        "ticket_number": [
            {
                "word": "7849648364314"
            }
        ],
        "fuel_surcharge": [
            {
                "word": "240.00"
            }
        ],
        "carrier": [
            {
                "word": "南航"
            },
            {
                "word": "南航"
            }
        ],
        "issued_date": [
            {
                "word": "2019-09-18"
            }
        ],
        "other_tax": [],
        "id_num": [
            {
                "word": "0789654700"
            }
        ],
        "destination_station": [
            {
                "word": "深圳"
            },
            {
                "word": "北京"
            }
        ],
        "name": [
            {
                "word": "姚佳"
            }
        ],
        "time": [
            {
                "word": "13:55"
            },
            {
                "word": "16:30"
            }
        ],
        "dev_fund": [
            {
                "word": "100.00"
            }
        ]
    },
    "log_id": "1280814270572920832",
    "words_result_num": 18
}

通用机打发票

支持对国家/地方税务局发行的横/竖版通用机打发票的23个关键字段进行结构化识别,包括发票类型、发票号码、发票代码、开票日期、合计金额大写、合计金额小写、商品名称、商品单位、商品单价、商品数量、商品金额、机打代码、机打号码、校验码、销售方名称、销售方纳税人识别号、购买方名称、购买方纳税人识别号、合计税额等。

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用通用机打发票
result = client.invoice(image, aip::null);
std::string url = 
result = client.invoiceUrl(url, aip::null);
//  如果有可选参数
std::map<std::string, std::string> options;
options["location"] = ""
result = client.invoice(image, options);
result = 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 联次

返回示例

{
    "log_id": 4423022131715883558,
    "direction": 0,
    "words_result_num": 22,
    "words_result": {
        "City": "",
        "InvoiceNum": "01445096",
        "SellerName": "百度餐饮店",
        "IndustrSort": "生活服务",
        "Province": "广东省",
        "CommodityAmount": [
            {
                "word": "183.00",
                "row": "1"
            }
        ],
        "InvoiceDate": "2020年07月28日",
        "PurchaserName": "中信建投证券股份有限公司",
        "CommodityNum": [],
        "InvoiceCode": "144001901511",
        "CommodityUnit": [],
        "SheetNum": "",
        "PurchaserRegisterNum": "9144223008453480X9",
        "Time": "",
        "CommodityPrice": [],
        "AmountInFiguers": "183.00",
        "AmountInWords": "壹佰捌拾叁元整",
        "CheckCode": "61042119820421061301",
        "TotalTax": "183.00",
        "InvoiceType": "广东通用机打发票",
        "SellerRegisterNum": "61042119820421061301",
        "CommodityName": [
            {
                "word": "餐费",
                "row": "1"
            }
        ]
    }
}

护照识别

支持对中国大陆护照个人资料页所有15个字段进行结构化识别,包括国家码、护照号、姓名、姓名拼音、性别、出生地点、出生日期、签发地点(不支持境外签发地)、签发日期、有效期、签发机关、护照类型、国籍、MRZCode1、MRZCode2。

Json::Value result;
std::string image;
aip::get_file_content("/assets/sample.jpg", &image);
// 调用护照识别
result = client.passport(image, aip::null);
std::string url = 
result = 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 识别内容

返回示例

{
    "log_id": 7377468409496932872,
    "words_result_num": 14,
    "words_result": {
        "国家码": {
            "location": {
                "width": 59,
                "top": 200,
                "left": 762,
                "height": 26
            },
            "words": "CHN"
        },
        "护照签发地点": {
            "location": {
                "width": 236,
                "top": 505,
                "left": 558,
                "height": 43
            },
            "words": "山东/SHANDONG"
        },
        "MRZCode2": {
            "location": {
                "width": 1252,
                "top": 797,
                "left": 145,
                "height": 88
            },
            "words": "E898657303CHNSDMO7O2<<<<<<<<<<<<<"
        },
        "有效期至": {
            "location": {
                "width": 287,
                "top": 528,
                "left": 955,
                "height": 46
            },
            "words": "20261004"
        },
        "签发机关": {
            "location": {
                "width": 271,
                "top": 583,
                "left": 552,
                "height": 42
            },
            "words": "出入境管理局"
        },
        "MRZCode1": {
            "location": {
                "width": 1201,
                "top": 781,
                "left": 162,
                "height": 45
            },
            "words": "PONSUN<<JIAJIA<<<<<<<<<<<<<<<<<<<<<<<<<<"
        },
        "护照号码": {
            "location": {
                "width": 237,
                "top": 215,
                "left": 994,
                "height": 48
            },
            "words": "E89865730"
        },
        "签发日期": {
            "location": {
                "width": 279,
                "top": 453,
                "left": 955,
                "height": 46
            },
            "words": "20161005"
        },
        "出生地点": {
            "location": {
                "width": 216,
                "top": 429,
                "left": 564,
                "height": 43
            },
            "words": "山东/SHANDONG"
        },
        "姓名": {
            "location": {
                "width": 159,
                "top": 247,
                "left": 581,
                "height": 34
            },
            "words": "孙嘉佳"
        },
        "姓名拼音": {
            "location": {
                "width": 229,
                "top": 279,
                "left": 578,
                "height": 41
            },
            "words": "SUN,JIAJIA"
        },
        "国籍": {
            "location": {
                "width": 209,
                "top": 366,
                "left": 695,
                "height": 42
            },
            "words": "中国/CHINESE"
        },
        "生日": {
            "location": {
                "width": 202,
                "top": 382,
                "left": 950,
                "height": 39
            },
            "words": "19950723"
        },
        "性别": {
            "location": {
                "width": 73,
                "top": 357,
                "left": 570,
                "height": 34
            },
            "words": "男/M"
        }
    }
}

网约车行程单识别

对各大主要服务商的网约车行程单进行结构化识别,包括滴滴打车、花小猪打车、高德地图、曹操出行、阳光出行,支持识别服务商、行程开始时间、行程结束时间、车型、总金额等16 个关键字段。

	Json::Value result;
	std::string image;
	aip::get_file_content("文件或图片路径", &image);
	std::string pdf_file;
	aip::get_file_content("文件或图片路径", &pdf_file);
	std::string url = "https//www.x.com/sample.jpg"
	// 调用网约车行程单识别
	result = client.onlineTaxiItinerary(image);
	result = client.onlineTaxiItineraryUrl(url);
	result = client.onlineTaxiItineraryPdf(pdf_file,aip::null);
	//  如果有可选参数
	std::map<std::string, std::string> options;
	options["pdf_file_num"] = 1
	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 参数有效时返回该字段

返回示例

{
    "log_id": 1385196013945356288,
    "words_result_num": 7
    "words_result": {
        "TotalFare": "2316",
        "EndTime": "2020-07-30 19:00",
        "Phone": "13000000000",
        "ServiceProvider": "滴滴企业版",
        "StartTime": "2020-07-01 16:00",
        "ApplicationDate": "2017-12-08",
        "ItemId": "3"
        "items": [
            {
                "ItemId": "1",
                "StartPlace": "鱼化寨地铁-D口",
                "PickupTime": "16:00",
                "CarType": "快车",
                "City": "西安市",
                "Distance": "9.7",
                "PickupDate": "20-07-01",
                "DestinationPlace": "创新港",
                "Fare": "20.86"
            },
            {
                "ItemId": "2",
                "StartPlace": "科学园东门",
                "PickupTime": "14:56",
                "CarType": "快车",
                "City": "西安市",
                "Distance": "91",
                "PickupDate": "20-07-02",
                "DestinationPlace": "鱼化寨地铁站",
                "Fare": "18.58"
            },
            {
                "ItemId": "3",
                "StartPlace": "中俄丝路创新园东门",
                "PickupTime": "19:00",
                "CarType": "快车",
                "City": "西安市",
                "Distance": "9.1",
                "PickupDate": "20-07-30",
                "DestinationPlace": "新门地铁站",
                "Fare": "20.38"
            },
        ],
     },   
}

磅单识别

结构化识别磅单的车牌号、打印时间、毛重、皮重、净重、发货单位、收货单位、单号8个关键字段,现阶段仅支持识别印刷体磅单。

	Json::Value result;
	std::string image;
	aip::get_file_content("文件或图片路径", &image);
	std::string url = "https//www.x.com/sample.jpg"
	std::string pdf_file;
	aip::get_file_content("文件或图片路径", &image);
	// 调用磅单识别
	result = client.weightNote(image,aip::null);
	result = client.weightNoteUrl(url,aip::null);
	result = client.weightNotePdf(pdf_file,aip::null);
	//  如果有可选参数
	std::map<std::string, std::string> options;
	options["pdf_file_num"] = 1
	options["probability"] = false
	result = client.weightNote(image, options);
	result = client.weightNoteUrl(url, options);
	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 参数有效时返回该字段

返回示例

{
    "words_result": [
        {
            "TareWeight": [
            {
                    "word": "14.20"
                }
            ],
            "CrossWeight": [
                {
                    "word": "50.70"
                }
            ],
            "PlateNum": [
                {
                    "word": "京A12356"
                }
            ],
            "SendingCompany": [
             {
                    "word": "宣化县耿矿煤业有限公司"
                }
            ],
            "DeliveryNumber": [
             {
                    "word": "278933000"
                }
            ],
            "ReceivingCompany": [
                {
                    "word": "宁夏市京裕达实业公司"
                }
            ],
            "PrintTime": [
                {
                    "word": "2020年1月1日"
                }
            ],
            "NetWeight": [
                {
                    "word": "36.50"
                }
            ]
        }
    ],
    "words_result_num": 1,
    "log_id": 1428311410130160734
}

医疗费用明细识别

支持识别全国医疗费用明细的姓名、日期、病人ID、总金额等关键字段,支持识别费用明细项目清单,包含项目类型、项目名称、单价、数量、规格、金额,其中北京地区识别效果最佳。

	Json::Value result;
	std::string url = "https//www.x.com/sample.jpg"
	std::string image;
	aip::get_file_content("文件或图片路径", &image);
	// 调用医疗费用明细识别
	result = client.medicalDetail(image,aip::null);
	result = client.medicalDetailUrl(url,aip::null);
	//  如果有可选参数
	std::map<std::string, std::string> options;
	options["location"] = true
	options["probability"] = false
	result = client.medicalDetail(image, options);
	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字段对应的识别结果

返回示例

{ 
    "log_id": 1397090241579319296,
    "words_result_num": 5,
    "words_result": {
       "PatientID": {
            "word": "23683829"
        },
        "TotalAmount": {
            "word": "600.00"
        },
        "Date": {
            "word": "2020年11月04日"
        },
        "Name": {
            "word": "范浩"
        },
        "CostDetail": [
            [
                {
                    "word_name": "清单项目名称",
                    "word": "普通过敏原(新)筛查"
                },
                {
                    "word_name": "单价",
                    "word": "580.00"
                },
                {
                    "word_name": "数量",
                    "word": "1.00"
                },
                {
                    "word_name": "金额",
                    "word": "580.00"
                },
                {
                    "word_name": "规格",
                    "word": "次"
                },
                {
                    "word_name": "项目类型",
                    "word": "化验费"
                }
            ],
            [
                {
                    "word_name": "清单项目名称",
                    "word": "总IgE测定"
                },
                {
                    "word_name": "单价",
                    "word": "20.00"
                },
                {
                    "word_name": "数量",
                    "word": "1.00"
                },
                {
                    "word_name": "金额",
                    "word": "20.00"
                },
                {
                    "word_name": "规格",
                    "word": "次"
                },
                {
                    "word_name": "项目类型",
                    "word": "化验费"
                }
            ]
        ],
    },
}

彩票识别

SDK 调用示例

	Json::Value result;
	std::string image;
	aip::get_file_content("文件或图片路径", &image);
	std::string url = "https//www.x.com/sample.jpg"
    
	// 调用彩票识别
	result = client.lottery_v1(image, options);
	result = client.lottery_v1_url(url, options);

接口详情

可参考API文档:彩票识别

iOCR通用版

SDK 调用示例

	Json::Value result;
	std::string image;
	std::string pdf_file;
	aip::get_file_content("文件或图片路径", &image);
	std::string url = "https//www.x.com/sample.jpg"
	aip::get_file_content("文件或图片路径", &pdf_file);
	
  // 调用iOCR通用版
	result = client.recognise_iocr_v1(image, aip::null);
	result = client.recognise_iocr_v1_url(url, aip::null);
	result = client.recognise_iocr_v1_pdf(pdf_file, aip::null);

接口详情

可参考API文档:iOCR通用版

出生证明识别

SDK 调用示例

	Json::Value result;
	std::string image;
	aip::get_file_content("文件或图片路径", &image);
	std::string url = "https//www.x.com/sample.jpg"
	
  // 调用出生证明识别
	result = client.birth_certificate_v1(image, aip::null);
	result = client.birth_certificate_v1_url(url, aip::null);

接口详情

可参考API文档:出生证明识别

定额发票识别

SDK 调用示例

	Json::Value result;
	std::string image;
	std::string pdf_file;
	aip::get_file_content("文件或图片路径", &image);
	std::string url = "https//www.x.com/sample.jpg"
	aip::get_file_content("文件或图片路径", &pdf_file);
	
  // 定额发票识别
	result = client.quota_invoice_v1(image, aip::null);
	result = client.quota_invoice_v1_url(url, aip::null);
	result = client.quota_invoice_v1_pdf(pdf_file, aip::null);

接口详情

可参考API文档:定额发票识别

图文转换器

SDK 调用示例

    // 图片文件
	std::string img_file_content;
    aip::get_file_content("图片文件路径", &img_file_content);
    // url
    std::string url = "https//www.x.com/sample.jpg"
    // pdf文件
    std::string pdf_file_content;
    aip::get_file_content("pdf文件路径", &pdf_file_content);
    
    Json::Value options;
    
    Json::Value result = ocr->doc_convert_request_v1(img_file_content, options);
    Json::Value result = ocr->doc_convert_request_v1_url(url.c_str(), options);
    Json::Value result = ocr->doc_convert_request_v1_pdf(pdf_file_content, options);
    
    // 获取结果
    std::string task_id = "任务ID";
    Json::Value result = ocr->doc_convert_result_v1(task_id);

接口详情

可参考API文档:图文转换器

表格文字识别同步接口

接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别同步接口

表格文字识别

接口已下线,请使用表格文字识别V2,历史版本可查看表格文字识别

表格识别结果

接口已下线,请使用表格文字识别V2,历史版本可查看表格识别结果

上一篇
快速入门
下一篇
错误信息