有奖捉虫:行业应用 & 管理与支持文档专题 HOT

1. 接口描述

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

本接口支持数学试题内容的识别和结构化输出,包括通用文本解析和小学/初中/高中数学公式解析能力(包括91种题型,180种符号),公式返回格式为 Latex 格式文本。

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

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

2. 输入参数

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

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:EduPaperOCR。
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编码后不超过 7M。图片下载时间不超过 3 秒。
图片的 ImageUrl、ImageBase64 必须提供一个,如果都提供,只使用 ImageUrl。
示例值:base64
ImageUrl String 图片的 Url 地址。
支持的图片格式:PNG、JPG、JPEG,暂不支持 GIF 格式。
支持的图片大小:所下载图片经 Base64 编码后不超过 7M。图片下载时间不超过 3 秒。
图片存储于腾讯云的 Url 可保障更高的下载速度和稳定性,建议图片存储于腾讯云。
非腾讯云存储的 Url 速度和稳定性可能受一定影响。
示例值:http://test
Config String 扩展配置信息。
配置格式:{"option1":value1,"option2":value2}
1. task_type:任务类型【0: 关闭版式分析与处理 1: 开启版式分析处理】可选参数,Int32类型,默认值为1
2. is_structuralization:是否结构化输出【true:返回包体同时返回通用和结构化输出 false:返回包体返回通用输出】 可选参数,Bool类型,默认值为true
3. if_readable_format:是否按照版式整合通用文本/公式输出结果 可选参数,Bool类型,默认值为false
示例:
{"task_type": 1,"is_structuralization": true,"if_readable_format": true}
示例值:{}

3. 输出参数

参数名称 类型 描述
EduPaperInfos Array of TextEduPaper 检测到的文本信息,具体内容请点击左侧链接。
示例值:{}
Angle Integer 图片旋转角度(角度制),文本的水平方向为0°;顺时针为正,逆时针为负。
示例值:0
QuestionBlockInfos Array of QuestionBlockObj 结构化方式输出,具体内容请点击左侧链接。
示例值:{}
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 数学试题识别示例代码

输入示例

POST / HTTP/1.1
Host: ocr.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: EduPaperOCR
<公共请求参数>

{
    "ImageUrl": "https://xx/a.jpg"
}

输出示例

{
    "Response": {
        "Angle": 0,
        "QuestionBlockInfos": [
            {
                "QuestionBboxCoord": {
                    "Y": 0,
                    "X": 0,
                    "Width": 0,
                    "Height": 0
                },
                "QuestionArr": [
                    {
                        "QuestionTextNo": "",
                        "QuestionTextType": 3,
                        "QuestionImageCoords": [
                            {
                                "Y": 0,
                                "X": 0,
                                "Width": 0,
                                "Height": 0
                            }
                        ],
                        "QuestionText": "题型4:已知函数的单调性求参数的取值范围",
                        "QuestionOptions": "[{\"option\":[]}]",
                        "QuestionSubquestion": "[]"
                    }
                ]
            },
            {
                "QuestionBboxCoord": {
                    "Y": 0,
                    "X": 0,
                    "Width": 0,
                    "Height": 0
                },
                "QuestionArr": [
                    {
                        "QuestionTextNo": "[例9]",
                        "QuestionTextType": 3,
                        "QuestionImageCoords": [
                            {
                                "Y": 0,
                                "X": 0,
                                "Width": 0,
                                "Height": 0
                            }
                        ],
                        "QuestionText": "(★★★)已知函数f(x)=\\frac{ax+1}{x+2}在区间(-2,+∞)上是增函数,试求a的取值范围.",
                        "QuestionOptions": "[{\"option\":[]}]",
                        "QuestionSubquestion": "[]"
                    }
                ]
            },
            {
                "QuestionBboxCoord": {
                    "Y": 0,
                    "X": 0,
                    "Width": 0,
                    "Height": 0
                },
                "QuestionArr": [
                    {
                        "QuestionTextNo": "[例10]",
                        "QuestionTextType": 1,
                        "QuestionImageCoords": [
                            {
                                "Y": 0,
                                "X": 0,
                                "Width": 0,
                                "Height": 0
                            }
                        ],
                        "QuestionText": "(★★★★)已知函数,若f(x)=\\left\\lbrace\\begin{array}{l}{(2a-1)x+a,}&{x\\geq1}\\\\{\\log_{a}x,}&{x&lt1}\\end{array}\\right.在(0,+∞)上单调递减,则a的取值范围为##{()}##",
                        "QuestionOptions": "[{\"option\":[\"$${\\\\quad(0,\\\\frac{1}{2})}$$\",\"$${\\\\quad(0,\\\\frac{1}{3}\\\\rbrack}$$\",\"$${\\\\quad\\\\lbrack\\\\frac{1}{3},\\\\frac{1}{2})}$$\",\"$${\\\\quad(\\\\frac{1}{2},1)}$$\"]}]",
                        "QuestionSubquestion": "[]"
                    }
                ]
            },
            {
                "QuestionBboxCoord": {
                    "Y": 0,
                    "X": 0,
                    "Width": 0,
                    "Height": 0
                },
                "QuestionArr": [
                    {
                        "QuestionTextNo": "[例11]",
                        "QuestionTextType": 1,
                        "QuestionImageCoords": [
                            {
                                "Y": 0,
                                "X": 0,
                                "Width": 0,
                                "Height": 0
                            }
                        ],
                        "QuestionText": "(★★★★★)设f(x)=\\left\\lbrace\\begin{array}{l}{a^{x},}&{x&lt0}\\\\{(a-3)x+4a,x\\geq0}\\end{array}\\right.,对任意的.x_{1}\\neqx_{2}都有\\frac{f(x_{1})-f(x_{2})}{x_{1}-x_{2}}&lt0成立,则a的取值范围是##{()}##",
                        "QuestionOptions": "[{\"option\":[\"$${\\\\quad(0,\\\\frac{1}{4}\\\\rbrack}$$\",\"(0,1)\",\"$${\\\\quad\\\\lbrack\\\\frac{1}{4},1)}$$\",\"(0,3)\"]}]",
                        "QuestionSubquestion": "[]"
                    }
                ]
            }
        ],
        "EduPaperInfos": [
            {
                "Item": "0",
                "DetectedText": "\\frac { f ( x _ { 1 } ) - f ( x _ { 2 } ) } { x _ { 1 } - x _ { 2 } } &lt 0  ",
                "Itemcoord": {
                    "X": 1188,
                    "Y": 1320,
                    "Width": 224,
                    "Height": 84
                }
            },
            {
                "Item": "0",
                "DetectedText": "f ( x ) = \\frac { a x + 1 } { x + 2 }  ",
                "Itemcoord": {
                    "X": 537,
                    "Y": 335,
                    "Width": 169,
                    "Height": 63
                }
            },
            {
                "Item": "0",
                "DetectedText": "D . \\quad ( \\frac { 1 } { 2 } , 1 )  ",
                "Itemcoord": {
                    "X": 1163,
                    "Y": 900,
                    "Width": 156,
                    "Height": 79
                }
            },
            {
                "Item": "0",
                "DetectedText": "C . \\quad \\lbrack \\frac { 1 } { 3 } , \\frac { 1 } { 2 } )  ",
                "Itemcoord": {
                    "X": 872,
                    "Y": 900,
                    "Width": 160,
                    "Height": 80
                }
            },
            {
                "Item": "0",
                "DetectedText": "B . \\quad ( 0 , \\frac { 1 } { 3 } \\rbrack  ",
                "Itemcoord": {
                    "X": 580,
                    "Y": 899,
                    "Width": 159,
                    "Height": 82
                }
            },
            {
                "Item": "0",
                "DetectedText": "A . \\quad ( 0 , \\frac { 1 } { 4 } \\rbrack  ",
                "Itemcoord": {
                    "X": 273,
                    "Y": 1499,
                    "Width": 163,
                    "Height": 79
                }
            },
            {
                "Item": "0",
                "DetectedText": "C . \\quad \\lbrack \\frac { 1 } { 4 } , 1 )  ",
                "Itemcoord": {
                    "X": 872,
                    "Y": 1495,
                    "Width": 148,
                    "Height": 81
                }
            },
            {
                "Item": "0",
                "DetectedText": "A . \\quad ( 0 , \\frac { 1 } { 2 } )  ",
                "Itemcoord": {
                    "X": 289,
                    "Y": 900,
                    "Width": 162,
                    "Height": 79
                }
            },
            {
                "Item": "0",
                "DetectedText": "f ( x ) = \\left\\lbrace\\begin{array}{l} { ( 2 a - 1 ) x + a , } & { x \\geq 1 } \\\\ { \\log _ { a } x , } & { x &lt 1 } \\end{array}\\right.  ",
                "Itemcoord": {
                    "X": 641,
                    "Y": 727,
                    "Width": 364,
                    "Height": 89
                }
            },
            {
                "Item": "0",
                "DetectedText": "f ( x ) = \\left\\lbrace\\begin{array}{l} { a ^ { x } , } & { x &lt 0 } \\\\ { ( a - 3 ) x + 4 a , x \\geq 0 } \\end{array}\\right.  ",
                "Itemcoord": {
                    "X": 514,
                    "Y": 1313,
                    "Width": 391,
                    "Height": 96
                }
            },
            {
                "Item": "0",
                "DetectedText": "x _ { 1 } \\neq x _ { 2 }  ",
                "Itemcoord": {
                    "X": 1040,
                    "Y": 1351,
                    "Width": 85,
                    "Height": 29
                }
            },
            {
                "Item": "1000",
                "DetectedText": "题型4:已知函数的单调性求参数的取值范围",
                "Itemcoord": {
                    "X": 282,
                    "Y": 233,
                    "Width": 765,
                    "Height": 41
                }
            },
            {
                "Item": "1000",
                "DetectedText": "[例9] (★★★) 已知函数",
                "Itemcoord": {
                    "X": 194,
                    "Y": 347,
                    "Width": 342,
                    "Height": 33
                }
            },
            {
                "Item": "1000",
                "DetectedText": "在区间(-2, +∞)上是增函数,试求a的取值范围.",
                "Itemcoord": {
                    "X": 708,
                    "Y": 345,
                    "Width": 634,
                    "Height": 37
                }
            },
            {
                "Item": "1000",
                "DetectedText": "[例10] (★★★★) 已知函数,若",
                "Itemcoord": {
                    "X": 193,
                    "Y": 749,
                    "Width": 447,
                    "Height": 38
                }
            },
            {
                "Item": "1000",
                "DetectedText": "在(0, +∞)上单调递减,则a的取",
                "Itemcoord": {
                    "X": 1029,
                    "Y": 747,
                    "Width": 444,
                    "Height": 38
                }
            },
            {
                "Item": "1000",
                "DetectedText": "值范围为( )",
                "Itemcoord": {
                    "X": 282,
                    "Y": 841,
                    "Width": 214,
                    "Height": 37
                }
            },
            {
                "Item": "1000",
                "DetectedText": "[例11] (★★★★★)设",
                "Itemcoord": {
                    "X": 194,
                    "Y": 1343,
                    "Width": 319,
                    "Height": 39
                }
            },
            {
                "Item": "1000",
                "DetectedText": ",对任意的.",
                "Itemcoord": {
                    "X": 914,
                    "Y": 1345,
                    "Width": 125,
                    "Height": 34
                }
            },
            {
                "Item": "1000",
                "DetectedText": "都有",
                "Itemcoord": {
                    "X": 1127,
                    "Y": 1345,
                    "Width": 55,
                    "Height": 34
                }
            },
            {
                "Item": "1000",
                "DetectedText": "成立,",
                "Itemcoord": {
                    "X": 1414,
                    "Y": 1346,
                    "Width": 67,
                    "Height": 32
                }
            },
            {
                "Item": "1000",
                "DetectedText": "则a的取值范围是( )",
                "Itemcoord": {
                    "X": 282,
                    "Y": 1434,
                    "Width": 336,
                    "Height": 42
                }
            },
            {
                "Item": "1000",
                "DetectedText": "B. (0, 1)",
                "Itemcoord": {
                    "X": 589,
                    "Y": 1515,
                    "Width": 128,
                    "Height": 38
                }
            },
            {
                "Item": "1000",
                "DetectedText": "D. (0,3)",
                "Itemcoord": {
                    "X": 1171,
                    "Y": 1516,
                    "Width": 135,
                    "Height": 37
                }
            },
            {
                "Item": "1000",
                "DetectedText": "2019年高三.数学.寒假文科 ",
                "Itemcoord": {
                    "X": 665,
                    "Y": 2208,
                    "Width": 368,
                    "Height": 33
                }
            },
            {
                "Item": "105",
                "DetectedText": "",
                "Itemcoord": {
                    "X": 406,
                    "Y": 843,
                    "Width": 90,
                    "Height": 35
                }
            },
            {
                "Item": "105",
                "DetectedText": "",
                "Itemcoord": {
                    "X": 524,
                    "Y": 1434,
                    "Width": 94,
                    "Height": 42
                }
            }
        ],
        "RequestId": "ab8a243b-0108-4e44-b3b0-4772b7046fb9"
    }
}

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

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

命令行工具

6. 错误码

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

错误码 描述
FailedOperation.DownLoadError 文件下载失败。
FailedOperation.EmptyImageError 图片内容为空。
FailedOperation.ImageDecodeFailed 图片解码失败。
FailedOperation.ImageNoText 图片中未检测到文本。
FailedOperation.OcrFailed OCR识别失败。
FailedOperation.UnKnowError 未知错误。
FailedOperation.UnOpenError 服务未开通。
InvalidParameterValue.InvalidParameterValueLimit 参数值错误。
LimitExceeded.TooLargeFileError 文件内容太大。
ResourceUnavailable.InArrears 帐号已欠费。
ResourceUnavailable.ResourcePackageRunOut 账号资源包耗尽。
ResourcesSoldOut.ChargeStatusException 计费状态异常。