1. 接口描述
接口请求域名: ocr.tencentcloudapi.com 。
试卷切题(仅检测)可将整页练习册、试卷或教辅中的题目进行自动切题,返回试题边框和题目元素的坐标位置。
默认接口请求频率限制:2次/秒。
默认接口请求频率限制:20次/秒。
推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。
2. 输入参数
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| Action | 是 | String | 公共参数,本接口取值:QuestionSplitLayoutOCR。 |
| Version | 是 | String | 公共参数,本接口取值:2018-11-19。 |
| Region | 否 | String | 公共参数,此参数为可选参数。 |
| ImageUrl | 否 | String | 图片的 Url 地址。支持的图片格式:PNG、JPG、JPEG,暂不支持 GIF 格式。支持的图片大小:所下载图片经 Base64 编码后不超过 10M。图片下载时间不超过 3 秒。支持的图片像素:需介于20-10000px之间。图片存储于腾讯云的 Url 可保障更高的下载速度和稳定性,建议图片存储于腾讯云。非腾讯云存储的 Url 速度和稳定性可能受一定影响。 示例值:https://ocr-demo-1254418846.cos.ap-guangzhou.myqcloud.com/document/SmartStructuralOCR/SmartStructuralPro1.png |
| ImageBase64 | 否 | String | 图片的 Base64 值。支持的图片格式:PNG、JPG、JPEG,暂不支持 GIF 格式。支持的图片大小:所下载图片经Base64编码后不超过 10M。图片下载时间不超过 3 秒。支持的图片像素:需介于20-10000px之间。图片的 ImageUrl、ImageBase64 必须提供一个,如果都提供,只使用 ImageUrl。 示例值:/9j/4AAQSkZJRg.....s97n//2Q== |
| IsPdf | 否 | Boolean | 是否开启PDF识别,默认值为false,开启后可同时支持图片和PDF的识别。 示例值:true |
| PdfPageNumber | 否 | Integer | 需要识别的PDF页面的对应页码,仅支持PDF单页识别,当上传文件为PDF且IsPdf参数值为true时有效,默认值为1。 示例值:1 |
| EnableImageCrop | 否 | Boolean | 是否开启切边增强和弯曲矫正,默认为false不开启 示例值:false |
| UseNewModel | 否 | Boolean | false: 使用当前默认模型 true: 使用新的多模态推理模型,速度更快推理效果更强,仅 EnableOnlyDetectBorder 为 true 时生效,公测中示例值:false |
3. 输出参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| QuestionInfo | Array of QuestionInfo | 检测到的文本信息 |
| RequestId | String | 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。 |
4. 示例
示例1 试卷切题
试卷切题
输入示例
POST / HTTP/1.1
Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: QuestionSplitLayoutOCR
<公共请求参数>
{
"ImageUrl": "https://qq.com/1.jpg"
}
输出示例
{
"Response": {
"QuestionInfo": [
{
"Angle": 0,
"Height": 3368,
"ImageBase64": "",
"OrgHeight": 3368,
"OrgWidth": 2188,
"ResultList": [
{
"Answer": [],
"Coord": [
{
"LeftBottom": {
"X": 197,
"Y": 1508
},
"LeftTop": {
"X": 197,
"Y": 568
},
"RightBottom": {
"X": 2019,
"Y": 1508
},
"RightTop": {
"X": 2019,
"Y": 568
}
}
],
"Figure": [
{
"Coord": {
"LeftBottom": {
"X": 197,
"Y": 1066
},
"LeftTop": {
"X": 197,
"Y": 568
},
"RightBottom": {
"X": 2019,
"Y": 1066
},
"RightTop": {
"X": 2019,
"Y": 568
}
},
"GroupType": "fill-in-the-blank",
"Index": 0,
"ResultList": null,
"Text": ""
}
],
"Option": [
{
"Coord": {
"LeftBottom": {
"X": 275,
"Y": 1230
},
"LeftTop": {
"X": 275,
"Y": 1169
},
"RightBottom": {
"X": 595,
"Y": 1230
},
"RightTop": {
"X": 595,
"Y": 1169
}
},
"GroupType": "multiple-choice",
"Index": 2,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 729,
"Y": 1232
},
"LeftTop": {
"X": 729,
"Y": 1174
},
"RightBottom": {
"X": 1083,
"Y": 1232
},
"RightTop": {
"X": 1083,
"Y": 1174
}
},
"GroupType": "multiple-choice",
"Index": 3,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 1218,
"Y": 1230
},
"LeftTop": {
"X": 1218,
"Y": 1172
},
"RightBottom": {
"X": 1564,
"Y": 1230
},
"RightTop": {
"X": 1564,
"Y": 1172
}
},
"GroupType": "multiple-choice",
"Index": 4,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 1696,
"Y": 1229
},
"LeftTop": {
"X": 1696,
"Y": 1169
},
"RightBottom": {
"X": 2002,
"Y": 1229
},
"RightTop": {
"X": 2002,
"Y": 1169
}
},
"GroupType": "multiple-choice",
"Index": 5,
"ResultList": null,
"Text": ""
}
],
"Parse": [],
"Question": [
{
"Coord": {
"LeftBottom": {
"X": 200,
"Y": 1148
},
"LeftTop": {
"X": 200,
"Y": 1073
},
"RightBottom": {
"X": 1761,
"Y": 1148
},
"RightTop": {
"X": 1761,
"Y": 1073
}
},
"GroupType": "multiple-choice",
"Index": 1,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 200,
"Y": 1508
},
"LeftTop": {
"X": 200,
"Y": 1239
},
"RightBottom": {
"X": 2019,
"Y": 1508
},
"RightTop": {
"X": 2019,
"Y": 1239
}
},
"GroupType": "fill-in-the-blank",
"Index": 6,
"ResultList": null,
"Text": ""
}
],
"Table": []
},
{
"Answer": [],
"Coord": [
{
"LeftBottom": {
"X": 111,
"Y": 3284
},
"LeftTop": {
"X": 111,
"Y": 1615
},
"RightBottom": {
"X": 2030,
"Y": 3284
},
"RightTop": {
"X": 2030,
"Y": 1615
}
}
],
"Figure": [
{
"Coord": {
"LeftBottom": {
"X": 1615,
"Y": 2490
},
"LeftTop": {
"X": 1615,
"Y": 2232
},
"RightBottom": {
"X": 2030,
"Y": 2490
},
"RightTop": {
"X": 2030,
"Y": 2232
}
},
"GroupType": "problem-solving",
"Index": 13,
"ResultList": null,
"Text": ""
}
],
"Option": [
{
"Coord": {
"LeftBottom": {
"X": 267,
"Y": 2120
},
"LeftTop": {
"X": 267,
"Y": 2047
},
"RightBottom": {
"X": 902,
"Y": 2120
},
"RightTop": {
"X": 902,
"Y": 2047
}
},
"GroupType": "multiple-choice",
"Index": 9,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 1133,
"Y": 2119
},
"LeftTop": {
"X": 1133,
"Y": 2060
},
"RightBottom": {
"X": 1963,
"Y": 2119
},
"RightTop": {
"X": 1963,
"Y": 2060
}
},
"GroupType": "multiple-choice",
"Index": 10,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 260,
"Y": 2209
},
"LeftTop": {
"X": 260,
"Y": 2136
},
"RightBottom": {
"X": 1085,
"Y": 2209
},
"RightTop": {
"X": 1085,
"Y": 2136
}
},
"GroupType": "multiple-choice",
"Index": 11,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 1133,
"Y": 2207
},
"LeftTop": {
"X": 1133,
"Y": 2151
},
"RightBottom": {
"X": 1918,
"Y": 2207
},
"RightTop": {
"X": 1918,
"Y": 2151
}
},
"GroupType": "multiple-choice",
"Index": 12,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 258,
"Y": 2834
},
"LeftTop": {
"X": 258,
"Y": 2771
},
"RightBottom": {
"X": 1746,
"Y": 2834
},
"RightTop": {
"X": 1746,
"Y": 2771
}
},
"GroupType": "multiple-choice",
"Index": 15,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 258,
"Y": 2927
},
"LeftTop": {
"X": 258,
"Y": 2861
},
"RightBottom": {
"X": 1300,
"Y": 2927
},
"RightTop": {
"X": 1300,
"Y": 2861
}
},
"GroupType": "multiple-choice",
"Index": 16,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 258,
"Y": 3013
},
"LeftTop": {
"X": 258,
"Y": 2950
},
"RightBottom": {
"X": 1973,
"Y": 3013
},
"RightTop": {
"X": 1973,
"Y": 2950
}
},
"GroupType": "multiple-choice",
"Index": 17,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 251,
"Y": 3101
},
"LeftTop": {
"X": 251,
"Y": 3039
},
"RightBottom": {
"X": 1725,
"Y": 3101
},
"RightTop": {
"X": 1725,
"Y": 3039
}
},
"GroupType": "multiple-choice",
"Index": 18,
"ResultList": null,
"Text": ""
}
],
"Parse": [],
"Question": [
{
"Coord": {
"LeftBottom": {
"X": 123,
"Y": 1682
},
"LeftTop": {
"X": 123,
"Y": 1615
},
"RightBottom": {
"X": 1649,
"Y": 1682
},
"RightTop": {
"X": 1649,
"Y": 1615
}
},
"GroupType": "problem-solving",
"Index": 7,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 123,
"Y": 2300
},
"LeftTop": {
"X": 123,
"Y": 1694
},
"RightBottom": {
"X": 1948,
"Y": 2300
},
"RightTop": {
"X": 1948,
"Y": 1694
}
},
"GroupType": "problem-solving",
"Index": 8,
"ResultList": null,
"Text": ""
},
{
"Coord": {
"LeftBottom": {
"X": 111,
"Y": 3284
},
"LeftTop": {
"X": 111,
"Y": 2500
},
"RightBottom": {
"X": 2026,
"Y": 3284
},
"RightTop": {
"X": 2026,
"Y": 2500
}
},
"GroupType": "problem-solving",
"Index": 14,
"ResultList": null,
"Text": ""
}
],
"Table": []
}
],
"Width": 2188
}
],
"RequestId": "7a534f1d-2bb1-4e87-b79a-f8d37d6ab265"
}
}
5. 开发者资源
腾讯云 API 平台
腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。
API Inspector
用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。
SDK
云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。
- Tencent Cloud SDK 3.0 for Python: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Java: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for PHP: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Go: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Node.js: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for .NET: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for C++: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Ruby: CNB, GitHub, Gitee
命令行工具
6. 错误码
以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码。
| 错误码 | 描述 |
|---|---|
| FailedOperation.DownLoadError | 文件下载失败。 |
| FailedOperation.ImageDecodeFailed | 图片解码失败。 |
| FailedOperation.OcrFailed | OCR识别失败。 |
| FailedOperation.UnKnowError | 未知错误。 |
| FailedOperation.UnOpenError | 服务未开通。 |
| InvalidParameterValue.InvalidParameterValueLimit | 参数值错误。 |
| LimitExceeded.TooLargeFileError | 文件内容太大。 |
| ResourceUnavailable.InArrears | 账号已欠费。 |
| ResourceUnavailable.ResourcePackageRunOut | 账号资源包耗尽。 |
| ResourcesSoldOut.ChargeStatusException | 计费状态异常。 |