跳到主要内容

文字识别API

接口描述

文字识别接口,支持返回位置。

请求说明

URL

https://openapi.sys303.com/api/cognitive/ocr

参数

Header参数
参数
Content-Typemultipart/form-data
X-Secret点击获取
Body参数
参数是否必选类型可选值范围说明
filestream-图像文件,大小不超过10M,最短边至少15px,最长边最大8192px
langint[0, 1, 2, 3]识别语言类型,默认藏文【0:藏文,1:中文,2:英文,3:中藏混合】

请求样例

curl --request POST \
--url https://openapi.sys303.com/api/cognitive/ocr \
--header 'Accept: */*' \
--header 'X-Secret: {X-Secret}' \
--header 'content-type: multipart/form-data' \
--form lang=0 \
--form 'file=@[object Object]'

返回说明

参数说明

字段是否必选类型状态说明
traceIdString-唯一的traceId,用于问题定位
msgIdString-业务状态码
msgString错误描述
datadict-识别结果数组
+ linesstring-识别结果字符串
++ textstring-当前行文字
++ leftint-文本行top位置
++ topint-文本行left位置
++ widthint-文本行宽度
++ heightint-文本行高度

返回样例

成功
{
"traceId": "0HNL06O44AU0U:00000001",
"msgId": "2000000",
"msg": "success",
"data": {
"lines": [
{
"text": "识别文字1",
"left": 105,
"top": 45,
"width": 355,
"height": 74
},
{
"text": "识别文字2",
"left": 241,
"top": 513,
"width": 81,
"height": 38
}
]
}
}
失败

认证失败:

{
"traceId": "0HNLN3J9DCJSE:00000001",
"msgId": "4011001",
"msg": "AuthFailed",
"data": null
}

传入参数错误:

{
"traceId": "0HNL06O44AU14:00000001",
"msgId": "500",
"msg": "Specified argument was out of the range of valid values. (Parameter 'langType')",
"data": null
}

次数不足:

{
"traceId": "0HNL06O44AU1F:00000001",
"msgId": "2001001",
"msg": "InsufficientInventory",
"data": null
}