服务端 API

英文识别

最近更新时间:2020-07-13 08:40:04

1. 接口描述

接口请求域名: ocr.tencentcloudapi.com 。

本接口支持图像英文文字的检测和识别,返回文字框位置与文字内容。支持多场景、任意版面下的英文、字母、数字和常见字符的识别,同时覆盖英文印刷体和英文手写体识别。

默认接口请求频率限制:10次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:EnglishOCR。
Version String 公共参数,本接口取值:2018-11-19。
Region String 公共参数,详见产品支持的 地域列表,本接口仅支持其中的: ap-beijing, ap-guangzhou, ap-hongkong, ap-shanghai, na-toronto
ImageBase64 String 图片的 Base64 值。
支持的图片格式:PNG、JPG、JPEG,暂不支持 GIF 格式。
支持的图片大小:所下载图片经Base64编码后不超过 3M。图片下载时间不超过 3 秒。
图片的 ImageUrl、ImageBase64 必须提供一个,如果都提供,只使用 ImageUrl。
ImageUrl String 图片的 Url 地址。
支持的图片格式:PNG、JPG、JPEG,暂不支持 GIF 格式。
支持的图片大小:所下载图片经 Base64 编码后不超过 3M。图片下载时间不超过 3 秒。
图片存储于腾讯云的 Url 可保障更高的下载速度和稳定性,建议图片存储于腾讯云。
非腾讯云存储的 Url 速度和稳定性可能受一定影响。
EnableCoordPoint Boolean 单词四点坐标开关,开启可返回图片中单词的四点坐标。
该参数默认值为false。
EnableCandWord Boolean 候选字开关,开启可返回识别时多个可能的候选字(每个候选字对应其置信度)。
该参数默认值为false。

3. 输出参数

参数名称 类型 描述
TextDetections Array of TextDetectionEn 检测到的文本信息,具体内容请点击左侧链接。
RequestId String 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 英文识别示例代码

输入示例

https://ocr.tencentcloudapi.com/?Action=EnglishOCR
&ImageUrl=https://xx/a.jpg
&<公共请求参数>

输出示例

{
  "Response": {
    "TextDetections": [
      {
        "DetectedText": "No matter how long the",
        "Confidence": 99,
        "Polygon": [
          {
            "X": 228,
            "Y": 244
          },
          {
            "X": 228,
            "Y": 269
          },
          {
            "X": 562,
            "Y": 270
          },
          {
            "X": 562,
            "Y": 245
          }
        ],
        "AdvancedInfo": "{}",
        "WordCoordPoint": [
          {
            "WordCoordinate": [
              {
                "X": 226,
                "Y": 270
              },
              {
                "X": 226,
                "Y": 241
              },
              {
                "X": 270,
                "Y": 242
              },
              {
                "X": 270,
                "Y": 271
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 278,
                "Y": 271
              },
              {
                "X": 279,
                "Y": 242
              },
              {
                "X": 368,
                "Y": 242
              },
              {
                "X": 368,
                "Y": 271
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 378,
                "Y": 271
              },
              {
                "X": 378,
                "Y": 242
              },
              {
                "X": 437,
                "Y": 242
              },
              {
                "X": 437,
                "Y": 271
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 446,
                "Y": 271
              },
              {
                "X": 446,
                "Y": 242
              },
              {
                "X": 502,
                "Y": 242
              },
              {
                "X": 502,
                "Y": 271
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 514,
                "Y": 271
              },
              {
                "X": 514,
                "Y": 242
              },
              {
                "X": 566,
                "Y": 243
              },
              {
                "X": 566,
                "Y": 272
              }
            ]
          }
        ],
        "CandWord": [
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "N"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "o"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "m"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "a"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "t"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "t"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "e"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "r"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "h"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "o"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "w"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "l"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "o"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "n"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "g"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "t"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "h"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "e"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          }
        ],
        "Words": [
          {
            "Confidence": 99,
            "Character": "No"
          },
          {
            "Confidence": 99,
            "Character": "matter"
          },
          {
            "Confidence": 99,
            "Character": "how"
          },
          {
            "Confidence": 99,
            "Character": "long"
          },
          {
            "Confidence": 99,
            "Character": "the"
          }
        ]
      },
      {
        "DetectedText": "night, the day will come.",
        "Confidence": 99,
        "Polygon": [
          {
            "X": 226,
            "Y": 303
          },
          {
            "X": 226,
            "Y": 331
          },
          {
            "X": 569,
            "Y": 331
          },
          {
            "X": 569,
            "Y": 303
          }
        ],
        "AdvancedInfo": "{}",
        "WordCoordPoint": [
          {
            "WordCoordinate": [
              {
                "X": 224,
                "Y": 333
              },
              {
                "X": 224,
                "Y": 301
              },
              {
                "X": 297,
                "Y": 301
              },
              {
                "X": 297,
                "Y": 333
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 298,
                "Y": 333
              },
              {
                "X": 298,
                "Y": 301
              },
              {
                "X": 305,
                "Y": 301
              },
              {
                "X": 305,
                "Y": 333
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 316,
                "Y": 333
              },
              {
                "X": 316,
                "Y": 301
              },
              {
                "X": 352,
                "Y": 301
              },
              {
                "X": 352,
                "Y": 333
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 365,
                "Y": 333
              },
              {
                "X": 365,
                "Y": 301
              },
              {
                "X": 423,
                "Y": 300
              },
              {
                "X": 423,
                "Y": 333
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 432,
                "Y": 333
              },
              {
                "X": 432,
                "Y": 300
              },
              {
                "X": 474,
                "Y": 300
              },
              {
                "X": 474,
                "Y": 332
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 483,
                "Y": 332
              },
              {
                "X": 483,
                "Y": 300
              },
              {
                "X": 565,
                "Y": 300
              },
              {
                "X": 565,
                "Y": 332
              }
            ]
          },
          {
            "WordCoordinate": [
              {
                "X": 567,
                "Y": 332
              },
              {
                "X": 567,
                "Y": 300
              },
              {
                "X": 591,
                "Y": 300
              },
              {
                "X": 591,
                "Y": 332
              }
            ]
          }
        ],
        "CandWord": [
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "n"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "i"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "g"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "h"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "t"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": ","
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "t"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "h"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "e"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "d"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "a"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "y"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "w"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "i"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "l"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "l"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "nil"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "c"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "o"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "m"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 100,
                "Character": "e"
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          },
          {
            "CandWords": [
              {
                "Confidence": 99,
                "Character": "."
              },
              {
                "Confidence": 0,
                "Character": "㊥"
              }
            ]
          }
        ],
        "Words": [
          {
            "Confidence": 99,
            "Character": "night"
          },
          {
            "Confidence": 99,
            "Character": ","
          },
          {
            "Confidence": 99,
            "Character": "the"
          },
          {
            "Confidence": 99,
            "Character": "day"
          },
          {
            "Confidence": 99,
            "Character": "will"
          },
          {
            "Confidence": 99,
            "Character": "come"
          },
          {
            "Confidence": 99,
            "Character": "."
          }
        ]
      }
    ],
    "RequestId": "f2b87b6d-37c4-402f-b8b0-a74686f8f838"
  }
}

5. 开发者资源

API Explorer

该工具提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力,能显著降低使用云 API 的难度,推荐使用。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
FailedOperation.DownLoadError 文件下载失败。
FailedOperation.EmptyImageError 图片内容为空。
FailedOperation.ImageDecodeFailed 图片解码失败。
FailedOperation.ImageNoText 图片中未检测到文本。
FailedOperation.LanguageNotSupport 输入的Language不支持。
FailedOperation.OcrFailed OCR识别失败。
FailedOperation.UnKnowError 未知错误。
FailedOperation.UnOpenError 服务未开通。
InvalidParameterValue.InvalidParameterValueLimit 参数值错误。
LimitExceeded.TooLargeFileError 文件内容太大。
ResourcesSoldOut.ChargeStatusException 计费状态异常。
目录