接入指引
请先查看接入指引了解具体接入方式,再参考此文档完成接入。
请求API
名称 | 内容 |
---|
请求方式 | POST |
Content-Type | application/x-www-form-urlencoded |
图片要求 | 1. 图片格式:JPG、JPEG、PNG、BMP等常见格式,建议使用JPG格式。 2. 图片文件大小:最大 5 MB。 |
输入参数
Query参数:
参数 | 可选/必选 | 类型 | 说明 |
---|
Action | 必选 | String | 接口名,取值:OCRNormal |
Version | 必选 | String | 版本号,取值:2020-08-26 |
Body参数:
参数 | 可选/必选 | 类型 | 说明 |
---|
image_base64 | 必选 | String | 图片base64编码 |
type | 可选 | String | 文字识别类型,默认"default"为中英文文字识别,"auto"支持多语种文字识别 |
approximate_pixel | 可选 | String | 文本行高度差距为approximate_pixel时近似为同一行,未选时默认为"0" |
mode | 可选 | String | 文字识别模式:"default"-默认模式、"text_block"-文本块模式 |
filter_thresh | 可选 | String | 置信分数低于filter_thresh的文本行将被过滤掉, 默认为"80", 最大为"100" |
data 字段说明
字段 | 类型 | 说明 | 备注 |
---|
line_texts | Array of String | 识别结果 | 文本识别结果 |
line_rects | Array of RectInfo | 文本行位置 | 识别结果中每一行的位置信息 |
chars | 2D Array of CharInfo | 文字信息 | 识别结果中每一行中的左右文字信息 |
polygons | 3D Array of int | 行矩形框信息(可能有倾斜矩形) | 识别每行矩形框四个点的坐标,[左上, 右上, 右下, 左下] |
RectInfo 字段说明
字段 | 类型 | 说明 | 备注 |
---|
x | int | 当前文字行的横坐标 | |
y | int | 当前文字行的纵坐标 | |
width | int | 当前文字行的宽度 | |
height | int | 当前文字行的高度 | |
CharInfo 字段说明
字段 | 类型 | 说明 | 备注 |
---|
x | int | 当前文字的横坐标 | |
y | int | 当前文字的纵坐标 | |
width | int | 当前文字行的宽度 | |
height | int | 当前文字行的高度 | |
score | float | 当前文字置信度 | |
char | string | 文字文本内容 | |
HttpCode | 错误码 | 错误消息 | 描述 |
---|
200 | 10000 | 无 | 请求成功 |
400 | 60103 | "Missing Input Parameters: empty input image" | 输入图片为空 |
400 | 50207 | "Image Decode Error: image format unsupported" | 图片解码错误,文件内容为空或格式错误 |
400 | 61301 | "Invalid Input Parameters: Input image can not be decoded" | 输入图片错误 |
返回值示例
返回值示例
{
"code":10000,
"data":{
"line_texts": [""],
"line_rects": [{
"x": 1,
"y": 2,
"width": 1,
"height": 1
}]
"chars": [[{
"x": 1,
"y": 2,
"width": 1,
"height": 1,
"score": 0.9,
"char": ""
}]]
"polygons": [[[1,2],[3,4],[5,6],[7,8]]]
},
"message":"Success",
"request_id":"6838889517957515275",
"time_elapsed":"41.897331ms"
}