资讯 社区 文档 控制台
技术能力
语音技术
文字识别
人脸与人体
图像技术
语言与知识
视频技术
AR与VR
数据智能
场景方案
部署方案
行业应用
智能教育
智能医疗
智能零售
智能工业
企业服务
智能政务
信息服务
智能园区

接口说明

通用文字识别

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("language_type", "CHN_ENG");
        options.put("detect_direction", "true");
        options.put("detect_language", "true");
        options.put("probability", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.basicGeneral(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.basicGeneral(file, options);
        System.out.println(res.toString(2));

        
        // 通用文字识别, 图片参数为远程url图片
        JSONObject res = client.basicGeneralUrl(url, options);
        System.out.println(res.toString(2));

    }

通用文字识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
url String 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
language_type String CHN_ENG
ENG
POR
FRE
GER
ITA
SPA
RUS
JAP
KOR
CHN_ENG 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语;
- KOR:韩语;
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language String true
false
false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
probability String true
false
是否返回识别结果中每一行的置信度

通用文字识别 返回数据参数详情

字段 必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array 定位和识别结果数组
+words string 识别结果字符串
probability object 行置信度信息;如果输入参数 probability = true 则输出
+average number 行置信度平均值
+variance number 行置信度方差
+min number 行置信度最小值

通用文字识别 返回示例

{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
    [
        {"words": " TSINGTAO"},
        {"words": "青島睥酒"}
    ]
}

通用文字识别(高精度版)

用户向服务请求识别某张图中的所有文字,相对于通用文字识别该产品精度更高,但是识别耗时会稍长。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("probability", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.basicAccurateGeneral(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.basicAccurateGeneral(file, options);
        System.out.println(res.toString(2));

    }

通用文字识别(高精度版) 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
probability String true
false
是否返回识别结果中每一行的置信度

通用文字识别(高精度版) 返回数据参数详情

字段 必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array 定位和识别结果数组
+words string 识别结果字符串
probability object 行置信度信息;如果输入参数 probability = true 则输出
+average number 行置信度平均值
+variance number 行置信度方差
+min number 行置信度最小值

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

参考通用文字识别返回示例

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

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("recognize_granularity", "big");
        options.put("language_type", "CHN_ENG");
        options.put("detect_direction", "true");
        options.put("detect_language", "true");
        options.put("vertexes_location", "true");
        options.put("probability", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.general(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.general(file, options);
        System.out.println(res.toString(2));

        
        // 通用文字识别(含位置信息版), 图片参数为远程url图片
        JSONObject res = client.generalUrl(url, options);
        System.out.println(res.toString(2));

    }

通用文字识别(含位置信息版) 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
url String 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
recognize_granularity String big - 不定位单字符位置
small - 定位单字符位置
small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
language_type String CHN_ENG
ENG
POR
FRE
GER
ITA
SPA
RUS
JAP
KOR
CHN_ENG 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语;
- KOR:韩语;
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language String true
false
false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
vertexes_location String true
false
false 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false
probability String true
false
是否返回识别结果中每一行的置信度
paragraph String true
false
是否输出段落信息
通用文字识别(含位置信息版) 返回数据参数详情
字段 必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id number 唯一的log id,用于问题定位
words_result array 定位和识别结果数组
words_result_num number 识别结果数,表示words_result的元素个数
+vertexes_location array 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在
++x number 水平坐标(坐标0点为左上角)
++y number 垂直坐标(坐标0点为左上角)
+location array 位置数组(坐标0点为左上角)
++left number 表示定位位置的长方形左上顶点的水平坐标
++top number 表示定位位置的长方形左上顶点的垂直坐标
++width number 表示定位位置的长方形的宽度
++height number 表示定位位置的长方形的高度
+words number 识别结果字符串
+chars array 单字符结果,recognize_granularity=small时存在
++location array 位置数组(坐标0点为左上角)
+++left number 表示定位位置的长方形左上顶点的水平坐标
+++top number 表示定位位置的长方形左上顶点的垂直坐标
+++width number 表示定位定位位置的长方形的宽度
+++height number 表示位置的长方形的高度
++char string 单字符识别结果
probability object 行置信度信息;如果输入参数 probability = true 则输出
+ average number 行置信度平均值
+ variance number 行置信度方差
+ min number 行置信度最小值

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

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

通用文字识别(含位置高精度版)

用户向服务请求识别某张图中的所有文字,并返回文字在图片中的坐标信息,相对于通用文字识别(含位置信息版)该产品精度更高,但是识别耗时会稍长。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("recognize_granularity", "big");
        options.put("detect_direction", "true");
        options.put("vertexes_location", "true");
        options.put("probability", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.accurateGeneral(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.accurateGeneral(file, options);
        System.out.println(res.toString(2));

    }

通用文字识别(含位置高精度版) 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
recognize_granularity String big - 不定位单字符位置
small - 定位单字符位置
small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
vertexes_location String true
false
false 是否返回文字外接多边形顶点位置,不支持单字位置。默认为false
probability String true
false
是否返回识别结果中每一行的置信度

通用文字识别(含位置高精度版) 返回数据参数详情

字段 必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id number 唯一的log id,用于问题定位
words_result array 定位和识别结果数组
words_result_num number 识别结果数,表示words_result的元素个数
+vertexes_location array 当前为四个顶点: 左上,右上,右下,左下。当vertexes_location=true时存在
++x number 水平坐标(坐标0点为左上角)
++y number 垂直坐标(坐标0点为左上角)
+location array 位置数组(坐标0点为左上角)
++left number 表示定位位置的长方形左上顶点的水平坐标
++top number 表示定位位置的长方形左上顶点的垂直坐标
++width number 表示定位位置的长方形的宽度
++height number 表示定位位置的长方形的高度
+words number 识别结果字符串
+chars array 单字符结果,recognize_granularity=small时存在
++location array 位置数组(坐标0点为左上角)
+++left number 表示定位位置的长方形左上顶点的水平坐标
+++top number 表示定位位置的长方形左上顶点的垂直坐标
+++width number 表示定位定位位置的长方形的宽度
+++height number 表示位置的长方形的高度
++char string 单字符识别结果
probability object 行置信度信息;如果输入参数 probability = true 则输出
+ average number 行置信度平均值
+ variance number 行置信度方差
+ min number 行置信度最小值

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

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

通用文字识别(含生僻字版)

【该服务已停止更新,如需更好的识别效果请使用通用文字识别(高精度版 / 高精度含位置版),此两项服务已扩充字库,可支持生僻字识别】字库范围更大,支持对图片中的生僻字进行识别

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("language_type", "CHN_ENG");
        options.put("detect_direction", "true");
        options.put("detect_language", "true");
        options.put("probability", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.enhancedGeneral(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.enhancedGeneral(file, options);
        System.out.println(res.toString(2));

        
        // 通用文字识别(含生僻字版), 图片参数为远程url图片
        JSONObject res = client.enhancedGeneralUrl(url, options);
        System.out.println(res.toString(2));

    }

通用文字识别(含生僻字版) 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
url String 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
language_type String CHN_ENG
ENG
POR
FRE
GER
ITA
SPA
RUS
JAP
KOR
CHN_ENG 识别语言类型,默认为CHN_ENG。可选值包括:
- CHN_ENG:中英文混合;
- ENG:英文;
- POR:葡萄牙语;
- FRE:法语;
- GER:德语;
- ITA:意大利语;
- SPA:西班牙语;
- RUS:俄语;
- JAP:日语;
- KOR:韩语;
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language String true
false
false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)
probability String true
false
是否返回识别结果中每一行的置信度

通用文字识别(含生僻字版) 返回数据参数详情

字段 是否必选 类型 说明
direction int32 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id uint64 唯一的log id,用于问题定位
words_result array() 识别结果数组
words_result_num uint32 识别结果数,表示words_result的元素个数
+words string 识别结果字符串
probability object 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值
+ average number 行置信度平均值
+ variance number 行置信度方差
+ min number 行置信度最小值

通用文字识别(含生僻字版) 返回示例

{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
    [
        {"words": " TSINGTAO"},
        {"words": "青島睥酒"}
    ]
}

网络图片文字识别

用户向服务请求识别一些网络上背景复杂,特殊字体的文字。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("detect_language", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.webImage(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.webImage(file, options);
        System.out.println(res.toString(2));

        
        // 网络图片文字识别, 图片参数为远程url图片
        JSONObject res = client.webImageUrl(url, options);
        System.out.println(res.toString(2));

    }

网络图片文字识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
url String 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式,当image字段存在时url字段失效
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_language String true
false
false 是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语)

网络图片文字识别 返回数据参数详情

字段 是否必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
log_id number 唯一的log id,用于问题定位
words_result array() 识别结果数组
words_result_num number 识别结果数,表示words_result的元素个数
+words string 识别结果字符串
probability object 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值
+ average number 行置信度平均值
+ variance number 行置信度方差
+ min number 行置信度最小值

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

{
"log_id": 2471272194,
"words_result_num": 2,
"words_result":
    [
        {"words": " TSINGTAO"},
        {"words": "青島睥酒"}
    ]
}

身份证识别

用户向服务请求识别身份证,身份证识别包括正面和背面。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("detect_risk", "false");
        
        String idCardSide = "back";
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.idcard(image, idCardSide, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.idcard(file, idCardSide, options);
        System.out.println(res.toString(2));

    }

身份证识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
id_card_side String front - 身份证含照片的一面
back - 身份证带国徽的一面
front:身份证含照片的一面;back:身份证带国徽的一面
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
detect_risk String true - 开启
false - 不开启
false 是否开启身份证风险类型(身份证复印件、临时身份证、身份证翻拍、修改过的身份证)功能,默认不开启,即:false。可选值:true-开启;false-不开启
detect_photo String true - 开启
false - 不开启
false 是否检测头像内容,默认不检测。可选值:true-检测头像并返回头像的 base64 编码及位置信息
detect_card String true - 开启
false - 不开启
false 是否检测身份证进行裁剪,默认不检测。可选值:true-检测身份证并返回证照的 base64 编码及位置信息

身份证识别 返回数据参数详情

字段 是否必选 类型 说明
direction number 图像方向,当detect_direction=true时存在。
- -1:未定义,
- 0:正向,
- 1: 逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
image_status string normal-识别正常
reversed_side-未摆正身份证
non_idcard-上传的图片中不包含身份证
blurred-身份证模糊
over_exposure-身份证关键字段反光或过曝
unknown-未知状态
risk_type string 输入参数 detect_risk = true 时,则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknow-其他未知情况
edit_tool string 如果参数 detect_risk = true 时,则返回此字段。如果检测身份证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值无此参数
log_id number 唯一的log id,用于问题定位
words_result array(object) 定位和识别结果数组
words_result_num number 识别结果数,表示words_result的元素个数
+location array(object) 位置数组(坐标0点为左上角)
++left number 表示定位位置的长方形左上顶点的水平坐标
++top number 表示定位位置的长方形左上顶点的垂直坐标
++width number 表示定位位置的长方形的宽度
++height number 表示定位位置的长方形的高度
+words string 识别结果字符串

身份证识别 返回示例

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

银行卡识别

识别银行卡并返回卡号和发卡行。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.bankcard(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.bankcard(file, options);
        System.out.println(res.toString(2));

    }

银行卡识别 请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据

银行卡识别 返回数据参数详情

参数 类型 是否必须 说明
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
    }
}

驾驶证识别

对机动车驾驶证所有关键字段进行识别。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.drivingLicense(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.drivingLicense(file, options);
        System.out.println(res.toString(2));

    }

驾驶证识别 请求参数详情

参数 是否必选 类型 可选值范围 说明
image 和image二选一 string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
url 和image二选一 string - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效
请注意关闭URL防盗链
detect_direction string true/false - false:默认值,不检测朝向,朝向是指输入图像是正常方向、逆时针旋转90/180/270度
- true:检测朝向
driving_license_side string front/back - front:默认值,识别驾驶证正页
- back:识别驾驶证副页
unified_valid_period bool true/false - false: 默认值,不进行归一化处理
- true: 归一化格式输出驾驶证的「有效起始日期」+「有效期限」及「有效期限」+「至」两种输出格式归一化为「有效起始日期」+「失效日期」
quality_warn string true/false 是否开启质量检测功能,仅在驾驶证正页识别时生效,
- false:默认值,不输出质量告警信息
- true: 输出驾驶证遮挡、不完整质量告警信息
risk_warn string true/false 是否开启风险检测功能,
- false:默认值,不输出风险告警信息
- true:开启,输出驾驶证复印、翻拍、PS等告警信息

驾驶证识别 返回数据参数详情

字段 是否必选 类型 说明
log_id uint64 唯一的log id,用于问题定位
direction int32 图像方向,当 detect_direction=true 时返回该字段。
- - 1:未定义,
- 0:正向,
- 1:逆时针90度,
- 2:逆时针180度,
- 3:逆时针270度
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result object 识别结果
+ words string 识别结果字符串
warn_infos array[] 当输入参数 driving_license_side=front,且 quality_warn=true 时输出,
- shield:驾驶证证照存在遮挡告警提示
- incomplete:驾驶证证照边框不完整告警提示
risk_type string 当输入参数 risk_warn=true 时返回识出的驾驶证的类型:normal-正常驾驶证;copy-复印件;screen-翻拍
edit_tool string 当输入参数 risk_warn=true 时返回,如果检测驾驶证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值为空

驾驶证识别 返回示例

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

行驶证识别

对机动车行驶证所有关键字段进行识别。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("detect_direction", "true");
        options.put("accuracy", "normal");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.vehicleLicense(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.vehicleLicense(file, options);
        System.out.println(res.toString(2));

    }

行驶证识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。
vehicle_license_side string front/back front - front:识别行驶证主页
- back:识别行驶证副页
unified string true/false false - false:不进行归一化处理
- true:对输出字段进行归一化处理,将新/老版行驶证的“注册登记日期/注册日期”统一为”注册日期“进行输出

行驶证识别 返回数据参数详情

字段 必选 类型 说明
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array(object) 识别结果数组
+words string 识别结果字符串

行驶证识别 返回示例

{
  "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": "小型轿车"
      }
    }
  }
}

车牌识别

识别机动车车牌,并返回号牌号码和车牌颜色。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("multi_detect", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.plateLicense(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.plateLicense(file, options);
        System.out.println(res.toString(2));

    }

车牌识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
multi_detect String true
false
false 是否检测多张车牌,默认为false,当置为true的时候可以对一张图片内的多张车牌进行识别

车牌识别 返回数据参数详情

参数 类型 是否必须 说明
log_id uint64 请求标识码,随机数,唯一
Color string 车牌颜色
number string 车牌号码

车牌识别 返回示例

{
    "log_id": 3583925545,
    "words_result": {
        "color": "blue",
        "number": "苏HS7766"
    }
}

营业执照识别

识别营业执照,并返回关键字段的值,包括单位名称、法人、地址、有效期、证件编号、社会信用代码等。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.businessLicense(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.businessLicense(file, options);
        System.out.println(res.toString(2));

    }

营业执照识别 请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据

营业执照识别 返回数据参数详情

参数 是否必须 类型 说明
log_id number 请求标识码,随机数,唯一。
words_result_num number 识别结果数,表示words_result的元素个数
words_result array(object) 识别结果数组
left number 表示定位位置的长方形左上顶点的水平坐标
top number 表示定位位置的长方形左上顶点的垂直坐标
width number 表示定位位置的长方形的宽度
height number 表示定位位置的长方形的高度
words string 识别结果字符串

营业执照识别 返回示例

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

通用票据识别

用户向服务请求识别医疗票据、增值税发票、出租车票、保险保单等票据类图片中的所有文字,并返回文字在图中的位置信息。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("recognize_granularity", "big");
        options.put("probability", "true");
        options.put("accuracy", "normal");
        options.put("detect_direction", "true");
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.receipt(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.receipt(file, options);
        System.out.println(res.toString(2));

    }

通用票据识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image mixed 本地图片路径或者图片二进制数据
recognize_granularity String big - 不定位单字符位置
small - 定位单字符位置
small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
probability String true
false
是否返回识别结果中每一行的置信度
accuracy String normal - 使用快速服务
normal 使用快速服务,1200ms左右时延;缺省或其它值使用高精度服务,1600ms左右时延
detect_direction String true
false
false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
- true:检测朝向;
- false:不检测朝向。

通用票据识别 返回数据参数详情

字段 是否必选 类型 说明
log_id number 唯一的log id,用于问题定位
words_result_num number 识别结果数,表示words_result的元素个数
words_result array() 定位和识别结果数组
location object 位置数组(坐标0点为左上角)
left number 表示定位位置的长方形左上顶点的水平坐标
top number 表示定位位置的长方形左上顶点的垂直坐标
width number 表示定位位置的长方形的宽度
height number 表示定位位置的长方形的高度
words string 识别结果字符串
chars array() 单字符结果,recognize_granularity=small时存在
location array() 位置数组(坐标0点为左上角)
left number 表示定位位置的长方形左上顶点的水平坐标
top number 表示定位位置的长方形左上顶点的垂直坐标
width number 表示定位定位位置的长方形的宽度
height number 表示位置的长方形的高度
char string 单字符识别结果
probability object 识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值

通用票据识别 返回示例

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

自定义模板文字识别

自定义模板文字识别,是针对百度官方没有推出相应的模板,但是当用户需要对某一类卡证/票据(如房产证、军官证、火车票等)进行结构化的提取内容时,可以使用该产品快速制作模板,进行识别。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        
        options.put("templateSign", "Nsdax2424asaAS791823112");
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.custom(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.custom(file, options);
        System.out.println(res.toString(2));
    }

自定义模板文字识别 请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据
templateSign String 您在自定义文字识别平台制作的模板的ID
classifierId 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"
                }
            ]
    ]
}

表格文字识别同步接口

自动识别表格线及表格内容,结构化输出表头、表尾及每个单元格的文字内容。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.form(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.form(file, options);
        System.out.println(res.toString(2));

    }

表格文字识别同步接口 请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据

表格文字识别同步接口 返回数据参数详情

字段 是否必选 类型 说明
log_id long 唯一的log id,用于问题定位
forms_result_num number
forms_result array(object) 识别结果

表格文字识别同步接口 返回示例

   {
        "log_id": 3445697108,
        "forms_result_num": 1,
        "forms_result": [
            {
                "body": [
                    {
                        "column": 0,
                        "probability": 0.99855202436447,
                        "row": 0,
                        "vertexes_location": [
                            {
                                "x": -2,
                                "y": 260
                            },
                            {
                                "x": 21,
                                "y": 244
                            },
                            {
                                "x": 35,
                                "y": 266
                            },
                            {
                                "x": 12,
                                "y": 282
                            }
                        ],
                        "words": "目"
                    },
                    {
                        "column": 3,
                        "probability": 0.99960500001907,
                        "row": 5,
                        "vertexes_location": [
                            {
                                "x": 603,
                                "y": 52
                            },
                            {
                                "x": 634,
                                "y": 32
                            },
                            {
                                "x": 646,
                                "y": 50
                            },
                            {
                                "x": 615,
                                "y": 71
                            }
                        ],
                        "words": "66"
                    },
                    {
                        "column": 3,
                        "probability": 0.99756097793579,
                        "row": 6,
                        "vertexes_location": [
                            {
                                "x": 634,
                                "y": 73
                            },
                            {
                                "x": 648,
                                "y": 63
                            },
                            {
                                "x": 657,
                                "y": 77
                            },
                            {
                                "x": 643,
                                "y": 86
                            }
                        ],
                        "words": "4"
                    },
                    {
                        "column": 3,
                        "probability": 0.96489900350571,
                        "row": 10,
                        "vertexes_location": [
                            {
                                "x": 699,
                                "y": 178
                            },
                            {
                                "x": 717,
                                "y": 167
                            },
                            {
                                "x": 727,
                                "y": 183
                            },
                            {
                                "x": 710,
                                "y": 194
                            }
                        ],
                        "words": "3,"
                    },
                    {
                        "column": 3,
                        "probability": 0.99809801578522,
                        "row": 14,
                        "vertexes_location": [
                            {
                                "x": 751,
                                "y": 296
                            },
                            {
                                "x": 786,
                                "y": 273
                            },
                            {
                                "x": 797,
                                "y": 289
                            },
                            {
                                "x": 761,
                                "y": 312
                            }
                        ],
                        "words": "206"
                    }
                ],
                "footer": [
                    {
                        "column": 0,
                        "probability": 0.99853301048279,
                        "row": 0,
                        "vertexes_location": [
                            {
                                "x": 605,
                                "y": 698
                            },
                            {
                                "x": 632,
                                "y": 680
                            },
                            {
                                "x": 643,
                                "y": 696
                            },
                            {
                                "x": 616,
                                "y": 714
                            }
                        ],
                        "words": "22"
                    }
                ],
                "header": [
                    {
                        "column": 0,
                        "probability": 0.94802802801132,
                        "row": 0,
                        "vertexes_location": [
                            {
                                "x": 183,
                                "y": 96
                            },
                            {
                                "x": 286,
                                "y": 29
                            },
                            {
                                "x": 301,
                                "y": 52
                            },
                            {
                                "x": 199,
                                "y": 120
                            }
                        ],
                        "words": "29月"
                    }
                ],
                "vertexes_location": [
                    {
                        "x": -154,
                        "y": 286
                    },
                    {
                        "x": 512,
                        "y": -153
                    },
                    {
                        "x": 953,
                        "y": 513
                    },
                    {
                        "x": 286,
                        "y": 953
                    }
                ]
            }
        ]
    }

表格文字识别

自动识别表格线及表格内容,结构化输出表头、表尾及每个单元格的文字内容。表格文字识别接口为异步接口,分为两个API:提交请求接口、获取结果接口。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        
        
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.tableRecognitionAsync(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.tableRecognitionAsync(file, options);
        System.out.println(res.toString(2));

    }

表格文字识别 请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据

表格文字识别 返回数据参数详情

字段 是否必选 类型 说明
log_id long 唯一的log id,用于问题定位
result list 返回的结果列表
+request_id string 该请求生成的request_id,后续使用该request_id获取识别结果

表格文字识别 返回示例

    {
        "result" : [
            {
                "request_id" : "1234_6789"
            }
        ],
        "log_id":149689853984104
    }

失败应答示例(详细的错误码说明见本文档底部):

    {
        "log_id": 149319909347709,
        "error_code": 282000
        "error_msg":"internal error"
    }

表格识别结果

获取表格文字识别结果。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("result_type", "json");
        
        String requestId = "23454320-23255";
        
        // 表格识别结果
        JSONObject res = client.tableResultGet(requestId, options);
        System.out.println(res.toString(2));

    }

表格识别结果 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
request_id String 发送表格文字识别请求时返回的request id
result_type String json
excel
excel 期望获取结果的类型,取值为“excel”时返回xls文件的地址,取值为“json”时返回json格式的字符串,默认为”excel”

表格识别结果 返回数据参数详情

字段 是否必选 类型 说明
log_id long 唯一的log id,用于问题定位
result object 返回的结果
+result_data string 识别结果字符串,如果request_type是excel,则返回excel的文件下载地址,如果request_type是json,则返回json格式的字符串
+percent int 表格识别进度(百分比)
+request_id string 该图片对应请求的request_id
+ret_code int 识别状态,1:任务未开始,2:进行中,3:已完成
+ret_msg string 识别状态信息,任务未开始,进行中,已完成

表格识别结果 返回示例

成功应答示例:

    {
        "result" : {
            "result_data" : "",
            "persent":100,
            "request_id": "149691317905102",
            "ret_code": 3
            "ret_msg": "已完成",
        },
        "log_id":149689853984104
    }

当request_type为excel时,result_data格式样例为:

    {
        "file_url":"https://ai.baidu.com/file/xxxfffddd"
    }

当request_type为json时,result_data格式样例为:

   {
        "form_num": 1,
        "forms": [
            {
                "header": [
                    {
                    "row": [
                        1
                    ],
                    "column": [
                        1,
                        2
                    ],
                    "word": "表头信息1",
                }
            ],
            "footer": [
                {
                    "row": [
                        1
                    ],
                    "column": [
                        1,
                        2
                    ],
                    "word": "表尾信息1",
                }
            ],
            "body": [
                {
                    "row": [
                        1
                    ],
                    "column": [
                        1,
                        2
                    ],
                    "word": "单元格文字",
                }
            ]
        }
    ]
    }

其中各个参数的说明(json方式返回结果时):

字段 是否必选 类型 说明
form_num int 表格数量(可能一张图片中包含多个表格)
forms list 表格内容信息的列表
+header list 每个表格中,表头数据的相关信息
+footer list 表尾的相关信息
+body list 表格主体部分的数据
++row list 该单元格占据的行号
++column list 该单元格占据的列号
++word string 该单元格中的文字信息

失败应答示例(详细的错误码说明见本文档底部):

   {
        "log_id": 149319909347709,
        "error_code": 282000
        "error_msg":"internal error"
    }

表格识别轮询接口

代码示例

调用表格识别请求,获取请求id之后轮询调用表格识别获取结果的接口。

public void tableRecognition(AipOcr client) {
    //异步接口

    //使用封装的同步轮询接口
    JSONObject jsonres = client.tableRecognizeToJson(file, 20000);
    System.out.println(jsonres.toString(2));

    JSONObject excelres = client.tableRecognizeToExcelUrl(file, 20000);
    System.out.println(excelres.toString(2));

}

请求参数

参数 类型 描述 是否必须
imgPath/imgData byte[] 图像文件路径或二进制数据
timeoutMiliseconds long 最长等待时间,超时将返回错误, 一般任务在20s完成

返回参数与表格识别结果接口返回相同

试卷分析与识别

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

public void sample(AipOcr client) {
    // 传入可选参数调用接口
    HashMap<String, String> options = new HashMap<String, String>();

    // 参数为本地图片路径
    String image = "test.jpg";
    JSONObject res = client.docAnalysis(image, options);
    System.out.println(res.toString(2));

    // 参数为本地图片二进制数组
    byte[] file = readImageFile(image);
    res = client.docAnalysis(file, options);
    System.out.println(res.toString(2));
}

识别结果请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image true string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少64px,最长边最大4096px。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,)
language_type false string CHN_ENG/ ENG 识别语言类型,默认为CHN_ENG 可选值包括:=CHN_ENG:中英文 =ENG:英文
result_type false string big/small 返回识别结果是按单行结果返回,还是按单字结果返回,默认为big。 =big:返回行识别结果 =small:返回行识别结果之上还会返回单字结果
detect_direction false string true/false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。其中, 0 :正向 1:逆时针旋转90度 2:逆时针旋转180度 3:逆时针旋转270度
line_probability false string true/false 是否返回每行识别结果的置信度。默认为false
words_type false string handwring_only/ handprint_mix 文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别
layout_analysis false string true/false 是否分析文档版面:包括图、表、标题、段落的分析输出

识别结果 返回数据参数详情

字段 是否必选 类型 说明
log_id true uint64 唯一的log id,用于问题定位
img_direction false int32 detect_direction=true时返回。检测到的图像朝向,0 :正向; 1:逆时针旋转90度;2:逆时针旋转180度;3:逆时针旋转270度
results_num true uint32 识别结果数,表示results的元素个数
results true array[] 识别结果数组
+words_type true string 文字属性(手写、印刷),handwriting 手写,print 印刷
+words true array[] 整行的识别结果数组。
++line_probability false array[] line_probability=true时返回。识别结果中每一行的置信度值,包含average:行置信度平均值,min:行置信度最小值
+++average false float 行置信度
+++min false float 整行中单字的最低置信度
++word true float 整行的识别结果
++words_location true array[] 整行的矩形框坐标。位置数组(坐标0点为左上角)
+++left true uint32 表示定位位置的长方形左上顶点的水平坐标
+++top true uint32 表示定位位置的长方形左上顶点的垂直坐标
+++width true uint32 表示定位定位位置的长方形的宽度
+++height true uint32 表示位置的长方形的高度
+chars false array[] result_type=small时返回。单字符结果数组。
++char false string result_type=small时返回。每个单字的内容。
++chars_location false array[] 每个单字的矩形框坐标。位置数组(坐标0点为左上角)
+++left false uint32 表示定位位置的长方形左上顶点的水平坐标
+++top false uint32 表示定位位置的长方形左上顶点的垂直坐标
+++width false uint32 表示定位定位位置的长方形的宽度
+++height false uint32 表示位置的长方形的高度
layouts_num false uint32 版面分析结果数,表示layout的元素个数
layouts false array[] 文档版面信息数组,包含表格、图、段落文本、标题等标签;标签的坐标位置;段落文本和表格内文本内容对应的行序号ID
+layout false string 版面分析的标签结果。表格:table, 图:figure, 文本:text, 标题:title
+layout_location false array[] 文档版面信息标签的位置,四个顶点: 左上,右上,右下,左下
++x false uint32 水平坐标(坐标0点为左上角)
++y false uint32 水平坐标(坐标0点为左上角)
+layout_idx false array[] 文档版面信息中的文本在results结果中的位置:版面文本标签对应的行序号ID为n,则此标签中的文本在results结果中第n+1条展示)

仪器仪表盘读数识别

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

public void sample(AipOcr client) {
    // 传入可选参数调用接口
    HashMap<String, String> options = new HashMap<String, String>();

    // 参数为本地图片路径
    String image = "test.jpg";
    JSONObject res = client.meter(image, options);
    System.out.println(res.toString(2));

    // 参数为本地图片二进制数组
    byte[] file = readImageFile(image);
    res = client.meter(file, options);
    System.out.println(res.toString(2));
}

识别结果请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image true string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px。支持jpg/jpeg/png/bmp格式.注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,)
probability false string true/false 是否返回每行识别结果的置信度。默认为false
poly_location false string true/false 位置信息返回形式,默认:false false:只给出识别结果所在长方形位置信息 true:除了默认的识别文字所在长方形的位置信息,还会给出文字所在区域的最小外接旋转矩形的4个点坐标信息

识别结果 返回数据参数详情

字段 是否必选 类型 说明
log_id true uint64 唯一的log id,用于问题定位
words_result true array[] 识别结果数组
words_result_num true uint32 识别结果数,表示words_result的元素个数
+words true string 识别结果字符串
+location true array[] 识别结果所在长方形位置信息
++left true uint32 表示定位位置的长方形左上顶点的水平坐标
++top true uint32 表示定位位置的长方形左上顶点的垂直坐标
++width true uint32 表示定位位置的长方形的宽度
++height true uint32 表示定位位置的长方形的高度
+probability false string probability=true时存在。识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值
+poly_location false array[] poly_location=true时存在。文字所在区域的外接四边形的4个点坐标信息

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

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();

        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.webimageLoc(image, options);
        System.out.println(res.toString(2));

        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.webimageLoc(file, options);
        System.out.println(res.toString(2));
    }

网络图片文字识别(含位置版) 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image true string - 图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,像素乘积不超过20482048(10241024以内图像处理效果最佳)。注意:图片的base64编码是不包含图片头的,如(data:image/jpg;base64,)
detect_direction false string true/false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: - true:检测朝向; - false:不检测朝向
probability false string true/false 是否返回每行识别结果的置信度。默认为false
poly_location false string true/false 是否返回文字所在区域的外接四边形的4个点坐标信息。默认为false
recognize_granularity false string big/small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置

识别结果 返回数据参数详情

字段 是否必选 类型 说明
log_id true uint64 唯一的log id,用于问题定位
direction false int32 图像方向,当detect_direction=true时存在。检测到的图像朝向: 0 :正向; 1:逆时针旋转90度; 2:逆时针旋转180度; 3:逆时针旋转270度
words_result true array[] 识别结果数组
words_result_num true uint32 识别结果数,表示words_result的元素个数
+words true string 整行的识别结果
+location true object 整行的矩形框坐标。位置数组(坐标0点为左上角)
++left true uint32 表示定位位置的长方形左上顶点的水平坐标
++top true uint32 表示定位位置的长方形左上顶点的垂直坐标
++width true uint32 表示定位位置的长方形的宽度
++height true uint32 表示定位位置的长方形的高度
+probability true string probability=true时存在。识别结果中每一行的置信度值,包含average:行置信度平均值,variance:行置信度方差,min:行置信度最小值
+poly_location true array[] poly_location=true时存在。文字所在区域的外接矩形的4个点坐标信息
++x true uint32 水平坐标(坐标0点为左上角)
++y true uint32 垂直坐标(坐标0点为左上角)
+chars false array[] 单字符结果,recognize_granularity=small时存在
++char false string 单字符识别结果
++location false object 每个单字的矩形框坐标。位置数组(坐标0点为左上角)
+++left false uint32 表示定位位置的长方形左上顶点的水平坐标
+++top false uint32 表示定位位置的长方形左上顶点的垂直坐标
+++width false uint32 表示定位定位位置的长方形的宽度
+++height false uint32 表示定位定位位置的长方形的高度

增值税发票识别

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();

        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.vatInvoice(image,EImgType.FILE, options);
        System.out.println(res.toString(2));
        // 参数为url
        String image = "http://test.jpg";
        JSONObject res = client.vatInvoice( image, EImgType.URL, options);
        System.out.println(res.toString(2));
        // 参数为本地pdf
        String image = "test.pdf";
        SONObject res = client.vatInvoice( image, EImgType.PDF, options);
        System.out.println(res.toString(2));
        
        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.vatInvoice(file, options);
        System.out.println(res.toString(2));
    }

请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据或url或者pdf文件
imageType EImgType FILE,URL,PDF 表示image 类型
type String 可选参数,进行识别的增值税发票类型,默认为 normal,可缺省normal:可识别增值税普票、专票、电子发票roll:可识别增值税卷票
返回参数
字段 是否必选 类型 说明
log_id uint64 唯一的log id,用于问题定位
words_result_num uint32 识别结果数,表示words_result的元素个数
words_result object{} 识别结果
InvoiceType string 发票种类
InvoiceTypeOrg string 发票名称
InvoiceCode string 发票代码
InvoiceNum string 发票号码
MachineNum string 机打号码。仅增值税卷票含有此参数
MachineCode string 机器编号。仅增值税卷票含有此参数
CheckCode string 校验码。增值税专票无此参数
InvoiceDate string 开票日期
PurchaserName string 购方名称
PurchaserRegisterNum string 购方纳税人识别号
PurchaserAddress string 购方地址及电话
PurchaserBank string 购方开户行及账号
Password string 密码区
Province string
City string
SheetNum string 联次
Agent string 是否代开
CommodityName array[] 货物名称
- row uint32 行号
- word string 内容
CommodityType array[] 规格型号
- row uint32 行号
- word string 内容
CommodityUnit array[] 单位
- row uint32 行号
- word string 内容
CommodityNum array[] 数量
- row uint32 行号
- word string 内容
CommodityPrice array[] 单价
- row uint32 行号
- word string 内容
CommodityAmount array[] 金额
- row uint32 行号
- word string 内容
CommodityTaxRate array[] 税率
- row uint32 行号
- word string 内容
CommodityTax array[] 税额
- row uint32 行号
- word string 内容
SellerName string 销售方名称
SellerRegisterNum string 销售方纳税人识别号
SellerAddress string 销售方地址及电话
SellerBank string 销售方开户行及账号
TotalAmount uint32 合计金额
TotalTax uint32 合计税额
AmountInWords string 价税合计(大写)
AmountInFiguers uint32 价税合计(小写)
Payee string 收款人
Checker string 复核
NoteDrawer string 开票人
Remarks string 备注

返回示例

{	
  "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 个关键字段,包括发票号码、代码、车号、日期、总金额、燃油附加费、叫车服务费、省、市、单价、里程、上车时间、下车时间等。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();

        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.taxiReceipt(image,EImgType.FILE, options);
        System.out.println(res.toString(2));

        // 参数为url
        String image = "http://test.jpg";
        JSONObject res = client.taxiReceipt(image,EImgType.URl, options);
        System.out.println(res.toString(2));
        
        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.taxiReceipt(file, options);
        System.out.println(res.toString(2));
    }

请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据或url
imageType EImgType FILE,URL 表示image 类型
返回参数
参数 类型 是否必须 说明
log_id uint64 请求标识码,随机数,唯一。
words_result_num uint32 识别结果数,表示words_result的元素个数
InvoiceCode string 发票代号
InvoiceNum string 发票号码
TaxiNum string 车牌号
Date string 日期
Time string 上下车时间
Fare string 总金额
FuelOilSurcharge string 燃油附加费
CallServiceSurcharge string 叫车服务费
Province string
City string
PricePerkm string 单价
Distance string 里程

返回示例

{
	"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码识别

支持对车辆挡风玻璃处的车架号码进行识别。

    public void sample(AipOcr client) {
         // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();

        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.vinCode(image,EImgType.FILE, options);
        System.out.println(res.toString(2));

        // 参数为url
        String image = "http://test.jpg";
        JSONObject res = client.vinCode(image,EImgType.URl, options);
        System.out.println(res.toString(2));
        
        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.vinCode(file, options);
        System.out.println(res.toString(2));
    }

请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据或url
imageType EImgType FILE,URL 表示image 类型

返回参数

字段 是否必选 类型 说明
log_id uint64 唯一的log id,用于问题定位
words_result array[] 定位和识别结果数组
location object{} 识别结果
words string VIN码识别结果
words_result_num int 识别结果数,表示words_result的元素个数

返回示例

{
	"log_id": 246589877,
	"words_result": [
		{
			"location": {
				"left": 124,
				"top": 11,
				"width": 58,
				"height": 359
			},
			"words": "LFV2A11K8D4010942"
		}
	],
	"words_result_num": 1
}

火车票识别

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

    public void sample(AipOcr client) {

         // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();

        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.trainTicket(image,EImgType.FILE, options);
        System.out.println(res.toString(2));

        // 参数为url
        String image = "http://test.jpg";
        JSONObject res = client.trainTicket(image,EImgType.URl, options);
        System.out.println(res.toString(2));
        
        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.trainTicket(file, options);
        System.out.println(res.toString(2));
    }

请求参数详情

参数名称 是否必选 类型 说明
image mixed 本地图片路径或者图片二进制数据或url
imageType EImgType FILE,URL 表示image 类型
返回参数
参数 类型 是否必须 说明
log_id uint64 请求标识码,随机数,唯一。
ticket_num string 车票号
starting_station string 始发站
train_num string 车次号
destination_station string 到达站
date string 出发日期
ticket_rates string 车票金额
seat_category string 席别
name string 乘客姓名
id_num string 身份证号
serial_number string 序列号
sales_station string 售站
time string 时间
seat_num string 座位号
返回示例
{
	"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%。

    public void sample(AipOcr client) {
         // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("recognize_granularity","big");
        // 参数为本地图片路径
        String image = "test.jpg";
        JSONObject res = client.numbers(image,options);
        System.out.println(res.toString(2));
        
        // 参数为本地图片二进制数组
        byte[] file = readImageFile(image);
        res = client.numbers(file, options);
        System.out.println(res.toString(2));
    }

请求参数详情

参数名称 是否必选 类型 说明
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
}

二维码识别

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        // 参数为二进制数组
        byte[] file = readFile("test.jpg");
        res = client.qrcode(file, options);
        System.out.println(res.toString(2));

        // 参数图片url
        String url = "http://localhost/test.jpg"
        res = client.qrcodeUrl(url, options);
        System.out.println(res.toString(2));    
    }

请求参数详情

参数 是否必选 类型 可选值范围 说明
image 和url二选一 string - 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )
要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
url 和image二选一 string - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效
请注意关闭URL防盗链

返回参数详情

字段 是否必选 类型 说明
log_id uint64 唯一的log id,用于问题定位
codes_result_num uint32 识别结果数,表示codes_result的元素个数
codes_result array[] 定位和识别结果数组
-type string 识别码类型条码类型包括:9种条形码(UPC_A、UPC_E、EAN_13、EAN_8、CODE_39、CODE_93、CODE_128、ITF、CODABAR),4种二维码(QR_CODE、DATA_MATRIX、AZTEC、PDF_417)
-text string 条形码识别内容,暂时只限于识别中英文结果

返回示例

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

机动车销售发票

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

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        // 参数为二进制数组
        byte[] file = readFile("test.jpg");
        res = client.vehicleInvoice(file, options);
        System.out.println(res.toString(2));

        // 参数图片url
        String url = "http://localhost/test.jpg"
        res = client.vehicleInvoiceUrl(url, options);
        System.out.println(res.toString(2));    
   }

请求参数详情

参数 是否必选 类型 可选值范围 说明
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个关键字段进行结构化识别,包括合格证编号、发证日期、车辆制造企业名、车辆品牌、车辆名称、车辆型号、车架号、车身颜色、发动机型号、发动机号、燃料种类、排量、功率、排放标准、轮胎数、轴距、轴数、转向形式、总质量、整备质量、驾驶室准乘人数、最高设计车速、车辆制造日期。

    public void sample(AipOcr client) {
        // 传入可选参数调用接口
        HashMap<String, String> options = new HashMap<String, String>();
        // 参数为二进制数组
        byte[] file = readFile("test.jpg");
        res = client.vehicleCertificate(file, options);
        System.out.println(res.toString(2));

        // 参数图片url
        String url = "http://localhost/test.jpg"
        res = client.vehicleCertificateUrl(url, options);
        System.out.println(res.toString(2));    
    }

请求参数详情

参数 是否必选 类型 可选值范围 说明
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": "陕汽牌"