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

接口说明

通用文字识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用文字识别, 图片参数为本地图片
    client.generalBasic(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["language_type"] = "CHN_ENG";
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别, 图片参数为本地图片
    client.generalBasic(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;
    
    var url = "https//www.x.com/sample.jpg";
    
    // 调用通用文字识别, 图片参数为远程url图片
    client.generalBasicUrl(url).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["language_type"] = "CHN_ENG";
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别, 图片参数为远程url图片
    client.generalBasicUrl(url, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "青島睥酒"}
    ]
}

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

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用文字识别(高精度版)
    client.accurateBasic(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别(高精度版)
    client.accurateBasic(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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 行置信度最小值

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

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

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

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用文字识别(含位置信息版), 图片参数为本地图片
    client.general(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var 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";
    
    // 带参数调用通用文字识别(含位置信息版), 图片参数为本地图片
    client.general(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;
    
    var url = "https//www.x.com/sample.jpg";
    
    // 调用通用文字识别(含位置信息版), 图片参数为远程url图片
    client.generalUrl(url).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var 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图片
    client.generalUrl(url, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "动"
            }
        ]
    }
    ...
]
}

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

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用文字识别(含位置高精度版)
    client.accurate(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["recognize_granularity"] = "big";
    options["detect_direction"] = "true";
    options["vertexes_location"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别(含位置高精度版)
    client.accurate(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "动"
            }
        ]
    }
    ...
]
}

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

某些场景中,图片中的中文不光有常用字,还包含了生僻字,这时用户需要对该图进行文字识别,应使用通用文字识别(含生僻字版)。

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用文字识别(含生僻字版), 图片参数为本地图片
    client.generalEnhance(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["language_type"] = "CHN_ENG";
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别(含生僻字版), 图片参数为本地图片
    client.generalEnhance(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;
    
    var url = "https//www.x.com/sample.jpg";
    
    // 调用通用文字识别(含生僻字版), 图片参数为远程url图片
    client.generalEnhanceUrl(url).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["language_type"] = "CHN_ENG";
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    options["probability"] = "true";
    
    // 带参数调用通用文字识别(含生僻字版), 图片参数为远程url图片
    client.generalEnhanceUrl(url, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "青島睥酒"}
    ]
}

网络图片文字识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用网络图片文字识别, 图片参数为本地图片
    client.webImage(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    
    // 带参数调用网络图片文字识别, 图片参数为本地图片
    client.webImage(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;
    
    var url = "https//www.x.com/sample.jpg";
    
    // 调用网络图片文字识别, 图片参数为远程url图片
    client.webImageUrl(url).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    options["detect_language"] = "true";
    
    // 带参数调用网络图片文字识别, 图片参数为远程url图片
    client.webImageUrl(url, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "青島睥酒"}
    ]
}

身份证识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    var idCardSide = "back";
    
    // 调用身份证识别
    client.idcard(image, idCardSide).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    options["detect_risk"] = "false";
    
    // 带参数调用身份证识别
    client.idcard(image, idCardSide, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

身份证识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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。可选值:true-开启;false-不开启

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

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

身份证识别 返回示例

{
    "log_id": 2648325511,
    "direction": 0,
    "image_status": "normal",
    "idcard_type": "normal",
    "edit_tool": "Adobe Photoshop CS3 Windows",
    "words_result": {
        "住址": {
            "location": {
                "left": 267,
                "top": 453,
                "width": 459,
                "height": 99
            },
            "words": "南京市江宁区弘景大道3889号"
        },
        "公民身份号码": {
            "location": {
                "left": 443,
                "top": 681,
                "width": 589,
                "height": 45
            },
            "words": "330881199904173914"
        },
        "出生": {
            "location": {
                "left": 270,
                "top": 355,
                "width": 357,
                "height": 45
            },
            "words": "19990417"
        },
        "姓名": {
            "location": {
                "left": 267,
                "top": 176,
                "width": 152,
                "height": 50
            },
            "words": "伍云龙"
        },
        "性别": {
            "location": {
                "left": 269,
                "top": 262,
                "width": 33,
                "height": 52
            },
            "words": "男"
        },
        "民族": {
            "location": {
                "left": 492,
                "top": 279,
                "width": 30,
                "height": 37
            },
            "words": "汉"
        }
    },
    "words_result_num": 6
}

银行卡识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用银行卡识别
    client.bankcard(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });

银行卡识别 请求参数详情

参数名称 是否必选 类型 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式

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

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

驾驶证识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用驾驶证识别
    client.drivingLicense(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    
    // 带参数调用驾驶证识别
    client.drivingLicense(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

驾驶证识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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(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"
      }
    }
  }
}

行驶证识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用行驶证识别
    client.vehicleLicense(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["detect_direction"] = "true";
    options["accuracy"] = "normal";
    
    // 带参数调用行驶证识别
    client.vehicleLicense(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

行驶证识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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": "小型轿车"
      }
    }
  }
}

车牌识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用车牌识别
    client.licensePlate(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["multi_detect"] = "true";
    
    // 带参数调用车牌识别
    client.licensePlate(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

车牌识别 请求参数详情

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
multi_detect 否 string true
false
false 是否检测多张车牌,默认为false,当置为true的时候可以对一张图片内的多张车牌进行识别

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

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

车牌识别 返回示例

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

营业执照识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用营业执照识别
    client.businessLicense(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });

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

参数名称 是否必选 类型 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式

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

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

通用票据识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    
    // 调用通用票据识别
    client.receipt(image).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });
    
    // 如果有可选参数
    var options = {};
    options["recognize_granularity"] = "big";
    options["probability"] = "true";
    options["accuracy"] = "normal";
    options["detect_direction"] = "true";
    
    // 带参数调用通用票据识别
    client.receipt(image, options).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });;

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

参数名称 是否必选 类型 可选值范围 默认值 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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
}

自定义模板文字识别

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

    var fs = require('fs');
    
    var image = fs.readFileSync("assets/example.jpg").toString("base64");
    var templateSign = "Nsdax2424asaAS791823112";
    
    // 调用自定义模板文字识别
    client.custom(image, {templateSign}).then(function(result) {
        console.log(JSON.stringify(result));
    }).catch(function(err) {
        // 如果发生网络错误
        console.log(err);
    });

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

参数名称 是否必选 类型 说明
image 是 string 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
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"
                }
            ]
    ]
}

试卷分析与识别

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

var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');

client.docAnalysis(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};
options["result_type"] = "json";

client.docAnalysis(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

识别结果 请求参数详情

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

仪器仪表盘读数识别

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

var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');

client.meter(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};
options["probability"] = "true";

client.meter(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

识别结果 请求参数详情

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

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

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

var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
client.webimageLoc(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};
options["probability"] = "true";
client.webimageLoc(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

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

参数名称 是否必选 类型 可选值范围 默认值 说明
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 表示定位定位位置的长方形的高度

增值税发票

//本地文件识别
var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
client.vatInvoice(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};
options["type"] = "normal";
let image= new Buffer(fs.readFileSync('./vin.jpeg')).toString('base64');
client.vatInvoice(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
//url识别
var url="http:/test.jpg";
client.vatInvoiceUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
//本地pdf文件识别
var pdf="./test.pdf";
client.vatInvoicePdf(pdf, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

出租车票识别

//本地文件识别
var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
client.taxiReceipt(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
//url识别
var url="http://test.jpg";
client.taxiReceiptUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

//本地文件识别
var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
client.vinCode(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
//url识别
var url="http://test.jpg";
client.vinCodeUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

火车票识别

//本地文件识别
var fs = require('fs');
var image = new Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
client.trainTicket(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
//url识别
var url="http://test.jpg";
client.trainTicketUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数名称 是否必选 类型 说明
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": "北京南站"
	}
}

数字识别

//本地文件识别
var fs = require('fs');
var image = new 
Buffer(fs.readFileSync('assets/OCR/table.jpg')).toString('base64');
var options= {};
options.recognize_granularity='big';
client.numbers(image,options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

二维码识别

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

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 二维码识别
$client.qrcode(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.qrcode(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.qrcodeUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数 是否必选 类型 可选值范围 说明
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个关键字段进行结构化识别,包括发票代码、发票号码、开票日期、机器编号、购买方名称、购买方身份证号码/组织机构代码、车辆类型、厂牌型号、产地、合格证号、发动机号码、车架号码、价税合计、价税合计小写、销货单位名称、电话、纳税人识别号、账号、地址、开户银行、税率、税额、主管税务机关及代码、不含税价格、限乘人数。

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 机动车销售发票
$client.vehicleInvoice(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.vehicleInvoice(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.vehicleInvoiceUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 车辆合格证
$client.vehicleCertificate(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.vehicleCertificate(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.vehicleCertificateUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数 是否必选 类型 可选值范围 说明
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 个字段进行结构化识别,包括户号、姓名、与户主关系、性别、出生地、民族、出生日期、身份证号、本市县其他住址、曾用名、籍贯、宗教信仰、身高、血型、文化程度、婚姻状况、兵役状况、服务处所、职业、何时由何地迁往本市、何时由何地迁往本址、登记日期。

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 户口本识别
$client.householdRegister(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.householdRegister(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.householdRegisterUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

手写文字识别

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

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 手写文字识别
$client.handwriting(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.handwriting(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.handwritingUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数 是否必选 类型 可选值范围 说明
image 和url二选一 string - 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )
要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
url 和image二选一 string - 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式,当image字段存在时url字段失效
请注意关闭URL防盗链
recognize_granularity 否 string big、small 是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置
probability 否 string true/false 是否返回识别结果中每一行的置信度,默认为false,不返回置信度
detect_direction 否 string true/false 是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括:
true:检测朝向;
false:不检测朝向

返回参数详情

字段 是否必选 类型 说明
log_id 是 uint64 唯一的log id,用于问题定位
words_result_num 是 uint32 识别结果数,表示words_result的元素个数
words_result 是 array[] 定位和识别结果数组
location 是 object{} 位置数组(坐标0点为左上角)
left 是 uint32 表示定位位置的长方形左上顶点的水平坐标
top 是 uint32 表示定位位置的长方形左上顶点的垂直坐标
width 是 uint32 表示定位位置的长方形的宽度
height 是 uint32 表示定位位置的长方形的高度
words 是 string 识别结果字符串
chars 否 array[] 单字符结果,recognize_granularity=small时存在
location 是 object{} 位置数组(坐标0点为左上角)
left 是 uint32 表示定位位置的长方形左上顶点的水平坐标
top 是 uint32 表示定位位置的长方形左上顶点的垂直坐标
width 是 uint32 表示定位定位位置的长方形的宽度
height 是 uint32 表示位置的长方形的高度
char 是 string 单字符识别结果
probability 否 float 当请求参数 probability=true 时返回该字段,表示识别结果中每一行的置信度值,包含:
- average: 行置信度平均值
- variance:行置信度方差
- min:行置信度最小值
direction 否 int32 图像方向,当detect_direction=true时存在
-1:未定义,
0:正向,
1: 逆时针90度,
2:逆时针180度,
3:逆时针270度

返回示例

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

飞机行程单识别

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

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 飞机行程单识别
$client.airTicket(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.airTicket(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.airTicketUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数 是否必选 类型 可选值范围 说明
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个关键字段进行结构化识别,包括发票类型、发票号码、发票代码、开票日期、合计金额大写、合计金额小写、商品名称、商品单位、商品单价、商品数量、商品金额、机打代码、机打号码、校验码、销售方名称、销售方纳税人识别号、购买方名称、购买方纳税人识别号、合计税额等。

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 通用机打发票
$client.invoice(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.invoice(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.invoiceUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

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

var fs = require('fs');

var image = new Buffer(fs.readFileSync('example.jpg')).toString('base64');// 护照识别
$client.passport(image).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

// 如果有可选参数
var options = {};

client.passport(image, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});
 // 参数图片url
var url = "https//www.x.com/sample.jpg"
client.passportUrl(url, options).then(function(result) {
    console.log(JSON.stringify(result));
}).catch(function(err) {
    // 如果发生网络错误
    console.log(err);
});

请求参数详情

参数 是否必选 类型 可选值范围 说明
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 个关键字段。

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

	var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	// 调用网约车行程单识别
	client.onlineTaxiItinerary(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.onlineTaxiItineraryUrl(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.onlineTaxiItineraryPdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});
	//  如果有可选参数
	var options = {};
	options["pdf_file_num", 1];
	client.onlineTaxiItineraryPdf(pdf_file, options).then(function(result) {
		console.log(JSON.stringify(result));
	});

请求参数详情

参数 是否必选 类型 说明
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个关键字段,现阶段仅支持识别印刷体磅单。

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

	var url = "https//www.x.com/sample.jpg";
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	// 调用磅单识别
	client.weightNote(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.weightNoteUrl(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.weightNotePdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});
	//  如果有可选参数
	var options = {};
	options["pdf_file_num", 1];
	options["probability", false];
	client.weightNote(image, options).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.weightNoteUrl(url, options).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.weightNotePdf(pdf_file, options).then(function(result) {
		console.log(JSON.stringify(result));
	});

请求参数详情

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

医疗费用明细识别

SDK 调用示例

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client = AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";

  // 调用医疗费用明细识别
	client.medicalDetail(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.medicalDetailUrl(url).then(function(result) {
		console.log(JSON.stringify(result));
	});

接口详情

可参考API文档:医疗费用明细识别

出生证明识别

SDK 调用示例

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client = AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";

  // 调用出生证明识别
	client.birthCertificateV1(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.birthCertificateV1Url(url).then(function(result) {
		console.log(JSON.stringify(result));
	});

接口详情

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

定额发票识别_旧

SDK 调用示例

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');

  // 调用定额发票识别_旧
	client.quotaInvoiceV1(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.quotaInvoiceV1Url(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.quotaInvoiceV1Pdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});

接口详情

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

印章识别

SDK 调用示例

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');

  // 调用印章识别
	client.sealV1(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.sealV1Url(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.sealV1Pdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});

接口详情

可参考API文档:印章识别

办公文档识别

SDK 调用示例

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');

  // 调用办公文档识别
	client.docAnalysisOfficeV1(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.docAnalysisOfficeV1Url(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.docAnalysisOfficeV1Pdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});

接口详情

可参考API文档:办公文档识别

医疗费用明细识别

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

	var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	// 调用医疗费用明细识别
	client.medicalDetail(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.medicalDetailUrl(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	//  如果有可选参数
	var options = {};
	options["location", ];
	options["probability", false];
	client.medicalDetail(image, options).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.medicalDetailUrl(url, options).then(function(result) {
		console.log(JSON.stringify(result));
	});

请求参数详情

参数 是否必选 类型 可选值范围 说明
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": "化验费"
                }
            ]
        ],
    },
}

图文转换器(接口版)--提交请求

图文转换器对应的接口版产品,可识别图片/PDF文件中的文本内容,进行智能版式分析,并转换为保留原文档版式的Word、Excel文档,返回文档下载连接,支持含表格、印章、手写等内容的文档。满足文档版式还原、企业档案电子化等信息管理需求。如需直接在线使用轻应用,可到控制台-图文转换器使用。

	let fs = require('fs');
	let AipOcrClient = require("../src/AipOcr");
	let client=AipOcr new AipOcrClient("APPID", 'AK', 'Sk');

  var image = new Buffer(fs.readFileSync('文件路径')).toString('base64');
	var url = "https//www.x.com/sample.jpg";
	var pdf_file = new Buffer(fs.readFileSync('文件路径')).toString('base64');

  // 调用图文转换器(接口版)--提交请求
	client.docConvertRequestV1(image).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.docConvertRequestV1Url(url).then(function(result) {
		console.log(JSON.stringify(result));
	});
	client.docConvertRequestV1Pdf(pdf_file).then(function(result) {
		console.log(JSON.stringify(result));
	});

请求参数详情

参数 是否必选 类型 说明
image 和 url/pdf_file 三选一 string 图像数据,base64编码后进行urlencode,需去掉编码头(data:image/jpeg;base64, )
要求base64编码和urlencode后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
优先级: image > url > pdf_file,当image字段存在时,url、pdf_file字段失效
url 和 image/pdf_file 三选一 string 图片完整URL,URL长度不超过1024字节,URL对应的图片base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/jpeg/png/bmp格式
优先级: image > url > pdf_file,当image字段存在时url字段失效
请注意关闭URL防盗链
pdf_file 和 image/url 三选一 string PDF文件,base64编码后进行urlencode,要求base64编码和urlencode后大小不不超过10M
优先级: image > url > pdf_file,当image、url字段存在时,pdf_file字段失效
pdf_file_num 否 string 需要识别的PDF文件的对应页码,当 pdf_file 参数有效时,识别传入页码的对应页面内容;若不传入,默认识别文件所有页,页码从1开始

返回参数详情

字段 类型 说明
success bool 当前请求状态; true 表示请求成功,false表示请求异常
log_id uint64 唯一的log id,用于问题定位
result dict 返回的结果列表
+ task_id string 该请求生成的task_id,后续使用该task_id获取识别结果
code int 成功状态码
message string 详情

返回示例

成功返回示例:

{
    "success":true,
    "log_id": 12345,
    "result":{
        "task_id":"task-xxxxxxx",
    },
    "code":1001,
    "message": "Create task successfully!"
}

失败返回示例(详细的错误码说明见API文档-错误码):

{
    "success":false,
    "log_id": 12345,
    "error_code": 216401,
    "error_msg": "Create task failed!"
}

图文转换器(接口版)--获取结果

    var task_id = "xxxxx";
    
    // 调用图文转换器(接口版)--获取结果
    client.tableGetresult(task_id).then(function(result) {
        console.log(JSON.stringify(result));
    });
    

请求参数详情

参数 是否必选 类型 说明
task_id 是 string 发送提交请求时返回的task_id

返回参数详情

字段 类型 说明
success bool 当前请求状态; true表示请求成功,false表示请求异常
log_id uint64 唯一的log id,用于问题定位
result dict 返回的结果列表
+ task_id string 该文件对应请求的task_id
+ ret_code int 识别状态,1:任务未开始;2:进行中;3:已完成
+ ret_msg string 识别状态信息:任务未开始;进行中;已完成
+ percent int 文档转换进度(百分比)
+ result_data dict 识别结果字符串,返回word、excel的文件分别的下载地址
+ +word string 还原后的word文件的下载地址,文件识别失败时返回""
+ +excel string 还原后的Excel文件的下载地址,若文档中没有表格则返回""
+ create_time datetime 任务创建时间
+ start_time datetime 任务开始时间
+ end_time datetime 任务结束时间
code int 成功状态码
message string 详情

返回示例

成功返回示例:

{
    "success":true,
    "log_id": "xxxxxx",
    "result":{
        "task_id":"task-xxxxxxx",
        "ret_code": 3,
        "ret_msg": "已完成",
        "percent": 100,
        "result_data": {
            "word": "word_download_url",
            "excel": "",
        },
        "create_time": "2023-01-17 11:06:12",
        "start_time": "2023-01-17 11:06:13",
        "end_time": "2023-01-17 11:06:15"
    },
    "code":1001,
    "message": "Query task successfully!""
}

若查询的task_id不存在, 返回result为{}。 请求失败响应体示例如下:

{
    "code":1001,

    "log_id":1635891796603052032,

    "message":"Query task successfully!",

    "result":{},

    "success":true
}

表格文字识别同步接口

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

表格文字识别

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

表格识别结果

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

表格识别接口

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

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