Skip to content

OCR 识别 ​

识别图片中的文字内容,返回字符串结果。

接口信息 ​

项目值
地址/api/ocr
方法POST
Content-Typeapplication/json
认证需要 Bearer Token
扣点普通用户扣点,管理员不扣点

请求头 ​

http
Authorization: Bearer <token>
Content-Type: application/json

请求体 ​

json
{
  "img_base64": "base64-image"
}
字段类型必填说明
img_base64string是待识别图片的 Base64 字符串

curl 示例 ​

bash
curl -X POST "$BASE_URL/api/ocr" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"img_base64\": \"$IMG_BASE64\"
  }"

返回示例 ​

json
{
  "result": "识别到的文字"
}

错误码 ​

状态码说明
401Token 无效或过期
402余额不足

后端调用 ​

python
Atc.OCR(data.img_base64)