高精识别 API

高精度文字识别与位置检测,不仅提取文字内容,还提供每个文字块的详细坐标信息

概述

高精识别 API 提供高精度文字识别和详细的位置信息。与标准文字识别不同,该 API 不仅返回提取的文字内容,还返回每个文字块的精确坐标,包括旋转矩形和四点坐标。

该 API 使用统一的 JSON 请求格式,接受 URL 引用或 base64 编码的图像数据。

认证

API 支持以下认证方式:

  • API 密钥: 通过查询参数传递您的 API 密钥 ?key=YOUR_API_KEY

提取文字及位置数据

从图像文件中提取文字,并获取每个文字块的详细位置信息,包括旋转矩形和四点坐标。

请求

POST /api/advanced-recognition

参数:

参数类型必需描述
documentobject文档对象
document.typestring固定值 "image_url"
document.image_urlstring图片 URL 或 base64 数据
filenamestring文件名(base64 数据时推荐提供)
keystringAPI 密钥(查询参数,已登录用户可选)

示例:

使用图片 URL:

curl -X POST "https://llmocr.com/api/advanced-recognition?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "image_url",
      "image_url": "https://llmocr.com/image.jpg"
    }
  }'

使用 Base64 图片数据:

curl -X POST "https://llmocr.com/api/advanced-recognition?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "image_url",
      "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA..."
    },
    "filename": "document.jpg"
  }'

响应

参数:

参数类型描述
idstring数据库记录 ID
filenamestring文件名
contentstring提取的文字内容(所有文字块用换行符连接)
ocrResultobject包含位置信息的详细 OCR 结果
formatstring输出格式,固定为 "json"
timestampnumber处理完成时间戳
payloadstringAPI 端点 URL

ocrResult.words_info 结构:

words_info 数组中的每一项包含:

字段类型描述
textstring文字块的文本内容
locationnumber[]四点坐标 [x1,y1,x2,y2,x3,y3,x4,y4](左上 → 右上 → 右下 → 左下)
rotate_rectnumber[]旋转矩形 [center_x, center_y, width, height, angle],角度范围:[-90, 90]

示例:

{
  "id": "12345",
  "filename": "document.jpg",
  "content": "第一行文字\n第二行文字",
  "ocrResult": {
    "words_info": [
      {
        "text": "第一行文字",
        "location": [150, 80, 400, 80, 400, 120, 150, 120],
        "rotate_rect": [275, 100, 250, 40, 0]
      },
      {
        "text": "第二行文字",
        "location": [150, 150, 400, 150, 400, 190, 150, 190],
        "rotate_rect": [275, 170, 250, 40, 0]
      }
    ]
  },
  "format": "json",
  "timestamp": 1640995200000,
  "payload": "https://llmocr.com/api/advanced-recognition?key=YOUR_API_KEY"
}
高精识别 API - LLMOCR Developer Guide