通用文字识别新版

一、接口描述

1. 功能描述

可同时识别手写体和印刷体,并支持判断字体类型是否是手写体,返回识别结果、文字位置和字体类型

2. 接口数据要求:

  1. 图片格式:base64编码
  2. 图片类型: jpg/jpeg/png
  3. 图片大小: 小于5M

3. 接口使用:

平台为每个API提供试用体验服务,您在AI市场选择“免费试用”规格下单后,即可开始体验业内领先的人工智能API服务。 免费试用服务具有调用量、QPS限制,如需更高性能的API服务,可以提交咨询工单,联系京东AI扩容购买。

在获得使用权限后,您可使用已经封装好的SDK/参照接口鉴权规则进行相应开发,整体流程详见 接入流程
用户需要使用图片base64编码去做请求,使用其他图片的base64编码请求成功时也会加入计费。

二、请求说明

1. 接口地址 :

https://aiapi.jd.com/jdai/ocr_universal_new

2. 请求方式:

 post

3. 请求参数

(1)query请求参数

公共请求参数

名称 类型 必填 示例值 描述
appkey String 80d2b762ecb86593f9668526920f46c 您的appkey,可在买家中心控制台中获取
timestamp long 1541491668060 请求的时间戳,精确到毫秒,timestamp有效期5分钟
sign String 2e148773a0337a8f2200ba90d445f083 签名,根据规则MD5(sectetkey+timestamp)

(2)header请求参数

业务请求参数

名称 类型 必填 示例值 描述
Content-Type String application/json 标准编码格式

(3)body请求参数

业务请求参数

名称 类型 必填 示例值 描述
businessId String "JDT-NUEHUB-COM-FACE" 固定值
appName String "FACE_ALGORITHM" 固定值
appAuthorityKey String "sADsk3+58E9yf/fUN9DmBA==" 固定值
cardType String "all" 需要识别的字体类型,手写体”handwriting“,印刷体”print“,手写体+印刷体"all"
imageItem ImageItem {...} 需要识别的图片
serialNo String "1621270610624-010221159145-1821391" 随机唯一

参数ImageItem说明,imgBase64、imgArr、imgUrl三选一

名称 类型 必填 示例值 描述
encryptionType String "NON" 指定图片加密方式
imgBase64 String 图像Base64编码值,去掉图片头"data:image/png;base64,", media_id=4AAQSk...(由于过长,不给出示例) 图片base64编码
imgArr byte[] 图像byte[]数组 图像byte[]数组
imgUrl String 图像URL地址 图像URL地址
imgType String COM 图片类型COM("通用图片")

(4)请求代码示例

建议您使用我们提供的SDK进行调用

三、返回说明

1.返回参数

(1)公共返回参数

名称 类型 示例值 描述
code string 1000 参见下方错误码-系统级错误码
charge boolean false 或 true false:不扣费, true:扣费
remainTimes long 1305 剩余调用次数;免费api:每天剩余调用次数;收费api:剩余次数;无限制时为-1
remainSeconds long 1223456 剩余调用时间(s);免费api:-1;收费api:剩余调用时间;无限制时为-1
msg string 查询成功 参见下方错误码-系统级错误码
result object {...} 查询结果

(2)业务返回参数

result参数信息

名称 类型 示例值 描述
code number 0 状态code
serialNo string 98a39e53-84d4-448e-9081-29f64a6cd984 请求id
msg string success 返回信息
blur float 102.3462 模糊程度(值越大越清晰)
location Object 见返回示例 检测字符边框
textsInfo Object 见返回示例 识别结果

location字段说明

名称 类型 示例值 描述
height int 581 边框高度
left int 143 (left,top)是矩形框中心点的坐标
top int 226 (left,top)是矩形框中心点的坐标
width int 865 边框宽度

textsInfo字段说明

名称 类型 示例值 描述
text string 手写体识别 识别的文本
type string handwriting 字体类型:手写体“handwriting",印刷体"print"
points List [{....}] 文本所在位置矩形顶点坐标[pt0, pt1, pt2, pt3]

2.返回示例

{
    "blur": 101.43827,
    "class": "com.jd.jr.face.business.platfrom.exprot.dto.resp.ocr.HandWritingAndPrintRecognitionResp",
    "code": 0,
    "location": {
        "class": "com.jd.jr.facecloud.common.export.dto.BoundingBox",
        "height": 581,
        "left": 143,
        "top": 226,
        "width": 865
    },
    "msg": "成功",
    "serialNo": "1677135139827-010024250244-141407",
    "textsInfo": [
        {
            "class": "com.jd.jr.facecloud.common.export.dto.ocr.TextsInfo",
            "extended": {},
            "points": [
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 143.0,
                    "y": 238.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 754.0,
                    "y": 226.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 756.0,
                    "y": 330.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 146.0,
                    "y": 344.0
                }
            ],
            "text": "中文手写体测试",
            "type": "handwriting"
        },
        {
            "class": "com.jd.jr.facecloud.common.export.dto.ocr.TextsInfo",
            "extended": {},
            "points": [
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 465.0,
                    "y": 730.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 1007.0,
                    "y": 722.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 1008.0,
                    "y": 800.0
                },
                {
                    "class": "com.jd.jr.facecloud.common.export.dto.ocr.Point",
                    "x": 466.0,
                    "y": 807.0
                }
            ],
            "text": "7计d10",
            "type": "print"
        }
    ],
    "timestamp": 1677135140202
}

四、错误码信息

1.系统级错误码

详见返回码

2.业务错误码

业务错误码(code) message 说明
10 "权限受限!" 参数错误
101 "操作失败!" 识别失败
4105 "算法平台接口调用失败" 系统异常
Copyright © JD AI Platform all right reserved,powered by GitbookFile Modify: 2023-03-02 19:30:39

results matching ""

    No results matching ""