文档中心
API调试

功能描述

  • 通用文档识别
  • 适用于常规文档图像
  • 上传图片返回文字识别结果以及文档区域信息

重要特性 详情描述
适用场景 默认支持常规的文档图像
文字方向 默认支持横向和纵向文字混合识别
印刷手写 默认支持手写和印刷判断以及印刷文字和手写文字混合识别
字符信息 可选返回完整的字符信息包括字符坐标和候选字等
版面分析 支持版面要素信息返回如段落列表表格等
表格分析 支持返回文档中的表格分析结果如单元格的行列信息等
语言种类 默认支持简体中文/繁体中文/英语/日语/韩语/法语/德语/葡萄牙语/西班牙语/意大利语/荷兰语/瑞典语/芬兰语/丹麦语/挪威语/匈牙利语/越南语/南非荷兰语/阿尔巴尼亚语/巴斯克语/加泰罗尼亚语/克罗地亚语/捷克语/爱沙尼亚语/冰岛语/爱尔兰语/拉丁语/拉脱维亚语/立陶宛语/马来语/波兰语/罗马尼亚语/斯洛伐克语/斯洛文尼亚语/斯瓦希里语/土耳其语/威尔士言/马其他语/克里奥尔语 /加利西亚语/世界语/菲律宾语/印度尼西亚语/阿塞拜疆语/俄语/保加利亚语/马其顿语/乌克兰语/塞尔维亚语/白俄罗斯语/希腊语/亚美尼亚语等共52种常见语言以及更多映射语言

请求URL

https://api.textin.com/ai/service/v2/recognize/document

HTTP请求方法

HTTP POST

请求头说明(Request Header)

请在HTTP请求中添加以下自定义Header。

header 名
x-ti-app-id 请登录后前往 “工作台-账号设置-开发者信息” 查看 x-ti-app-id
x-ti-secret-code 请登录后前往 “工作台-账号设置-开发者信息” 查看 x-ti-secret-code

URL参数(Parameters)

URL参数指以 {参数名}={参数值} 形式拼接到 URL 上的键值对。它以 ? 开头,不同参数之间使用 & 连接。形如 ?p1=v1&p2=v2
参数名 数据类型 是否必填 允许的值 描述
character integer 0, 1
  • 返回完整的字符信息包括字符坐标和候选字等,默认关闭
straighten integer 0, 1
  • 坐标系选项,默认关闭并且所有结果返回均以原图为参照系
  • 若打开则返回结果的所有坐标点均以正置图像作为参照系
  • 调用者需要注意图像和API结果的角度关系

请求体说明(Request Body)

Content-Type: application/octet-stream

要上传的图片,目前支持jpg, png, bmp, pdf, tiff, 单帧gif等大部分格式.

请注意,请求体的数据格式为文件的二进制流,非 FormData 或其他格式。文件大小不超过 10M,图像宽高须介于 20 和 10000(像素)之间。

响应体说明(Response Data)

Content-Type: application/json

JSON结构说明如下:

字段名 类型 描述
code integer 错误码,详见“错误码说明”
message string

错误信息

version string

接口版本号。

duration number

服务时间消耗,单位是毫秒(ms)。

result object
+ angle integer

图像角度, 定义0度为人类阅读文字的图像方向,称为正置图像, 本字段表示输入图像是正置图像进行顺时针若干角度的旋转所得。

  • 0: ▲
  • 90: ▶
  • 180: ▼
  • 270: ◀
+ width integer

输入图像的宽度。

+ height integer

输入图像的高度。

+ lines array

以文本行为单位的识别结果

   ++ text string

识别内容字符串

   ++ score number

识别置信度

   ++ type string

文本类型,用于表示文字的形态。 当前版本下,文本类型包括:

  • text(文本)
  • stamp(印章)
  • formula(公式)
   ++ position array

以长度为8的整形数组表示四边形, 语义左上角为起始点顺时针构成闭合区域。

   ++ angle integer

图像角度, 定义0度为人类阅读文字的图像方向,称为正置图像, 本字段表示输入图像是正置图像进行顺时针若干角度的旋转所得。

  • 0: ▲
  • 90: ▶
  • 180: ▼
  • 270: ◀
   ++ direction integer

文字阅读方向。

  • -1: 其他
  • 0: 单字
  • 1: 横向
  • 2: 纵向
   ++ handwritten integer

文字是否手写所得。

  • -1: 未知
  • 0: 非手写文字, 一般为印刷文字
  • 1: 文字手写, 一般具备明显的书写特征
   ++ char_scores array

字符置信度,值域范围0-1。 设置character=1时输出。

   ++ char_centers array

字符中心点。 设置character=1时输出。

   ++ char_positions array

字符四边形点坐标,以顺时针构成闭合区域。 设置character=1时输出。

   ++ char_candidates array

候选字数组,表示每一个字符的候选,与候选置信度配套使用。 设置character=1时输出。

   ++ char_candidates_score array

候选字置信度数组,表示每一个候选字符的置信度,与候选字符配套使用。 设置character=1时输出。

   ++ area_index integer

区域编号,属于同一个段落就会共享一个编号。 当设置apply_layout=1时输出。

   ++ area_type string

区域类型。 当设置apply_layout=1时输出。

   ++ attributes object

(optional) 文本行的额外属性, 不同模型不同设置会不一样。

    +++ print integer

(optional) 属性索引值, 对应数组在attribute_map里面, 开关打开且模型支持时输出。

+ areas array

区域数组。

   ++ index integer

区域编号

   ++ score number

区域置信度

   ++ type string

区域类型常用于表示段落等区域信息。 当前版本下,区域类型包括:

  • paragraph(段落)
  • list(列表)
  • edge(页眉页脚)
  • image(图像)
  • stamp(印章)
  • formula(公式)
  • watermark(水印)
  • table(有线表格)
  • borderless_table(无线表格)
   ++ position array

区域多边形点坐标, 顺时针构成闭合区域。

   ++ text string

当区域类型为段落,则内部的若干文本行是语义连续的文字,可以把所有文字串连起来。

   ++ attributes object

(optional) 文本行的额外属性, 不同模型不同设置会不一样。

    +++ print integer

(optional) 属性索引值, 对应数组在attribute_map里面,模型支持时输出。

+ tables array

表格数组。 由于一张图像中会存在一个或者多个表格,所以数组中有对应若干个表格对象。 同时为了完整输出图像中表格以外区域的文字,表格数组中存在一个对象为“非表格”区域,存储所有表格外文字。

   ++ position array

以长度为8的整形数组表示四边形, 语义左上角为起始点顺时针构成闭合区域。

   ++ area_index integer

区域编号,与areas一致。

   ++ area_type string

区域类型,与areas一致。

   ++ type string

表格类型:

  • plain (文本区域而非表格区域): 仅返回文本行信息即字段"lines"
  • table_with_line (有线表格): 仅返回单元格信息即字段"table_cells"
  • table_without_line (无线表格): 仅返回单元格信息即字段"table_cells"
   ++ table_rows integer

表格行数。

   ++ table_cols integer

表格列数。

   ++ height_of_rows array

表格正向放置时每行的高度,与图像旋转角无关,单位是像素(px)。

   ++ width_of_cols array

表格正向放置时每列的宽度,与图像旋转角无关。

   ++ table_lines array

表格线段数组

    +++ position array

线段起始终止端点坐标以及其类型。

    +++ direction string

横向和纵向

   ++ table_cells array

单元格数组,当前区域类型为有线表格或者无线表格时返回本字段。

    +++ start_row integer

单元格的起始行。

    +++ start_col integer

单元格的起始列。

    +++ end_row integer

单元格的结束行。

    +++ end_col integer

单元格的结束列。

    +++ borders object

单元格的框线。

     ++++ top integer

单元格的上边框。

  • 0: 无边框
  • 1: 单实线
     ++++ bottom integer

单元格的上边框。

  • 0: 无边框
  • 1: 单实线
     ++++ left integer

单元格的上边框。

  • 0: 无边框
  • 1: 单实线
     ++++ right integer

单元格的上边框。

  • 0: 无边框
  • 1: 单实线
    +++ text string

单元格内所有识别结果的合并字符串。

    +++ position array

单元格的位置信息, 以长度为8的整形数组表示四边形, 语义左上角为起始点顺时针构成闭合区域。

    +++ lines array

单元格内的文本行,会存在一个或者多个。

     ++++ text string

识别内容字符串

     ++++ score number

识别置信度

     ++++ type string

文本类型,用于表示文字的形态。 当前版本下,文本类型包括:

  • text(文本)
  • stamp(印章)
  • formula(公式)
     ++++ position array

以长度为8的整形数组表示四边形, 语义左上角为起始点顺时针构成闭合区域。

     ++++ angle integer

图像角度, 定义0度为人类阅读文字的图像方向,称为正置图像, 本字段表示输入图像是正置图像进行顺时针若干角度的旋转所得。

  • 0: ▲
  • 90: ▶
  • 180: ▼
  • 270: ◀
     ++++ direction integer

文字阅读方向。

  • -1: 其他
  • 0: 单字
  • 1: 横向
  • 2: 纵向
     ++++ handwritten integer

文字是否手写所得。

  • -1: 未知
  • 0: 非手写文字, 一般为印刷文字
  • 1: 文字手写, 一般具备明显的书写特征
     ++++ char_scores array

字符置信度,值域范围0-1。 设置character=1时输出。

     ++++ char_centers array

字符中心点。 设置character=1时输出。

     ++++ char_positions array

字符四边形点坐标,以顺时针构成闭合区域。 设置character=1时输出。

     ++++ char_candidates array

候选字数组,表示每一个字符的候选,与候选置信度配套使用。 设置character=1时输出。

     ++++ char_candidates_score array

候选字置信度数组,表示每一个候选字符的置信度,与候选字符配套使用。 设置character=1时输出。

   ++ lines array

若当前区域类型为非表格区域,则不返回单元格字段而是返回本字段表示文本行数组。

    +++ text string

识别内容字符串

    +++ score number

识别置信度

    +++ type string

文本类型,用于表示文字的形态。 当前版本下,文本类型包括:

  • text(文本)
  • stamp(印章)
  • formula(公式)
    +++ position array

以长度为8的整形数组表示四边形, 语义左上角为起始点顺时针构成闭合区域。

    +++ angle integer

图像角度, 定义0度为人类阅读文字的图像方向,称为正置图像, 本字段表示输入图像是正置图像进行顺时针若干角度的旋转所得。

  • 0: ▲
  • 90: ▶
  • 180: ▼
  • 270: ◀
    +++ direction integer

文字阅读方向。

  • -1: 其他
  • 0: 单字
  • 1: 横向
  • 2: 纵向
    +++ handwritten integer

文字是否手写所得。

  • -1: 未知
  • 0: 非手写文字, 一般为印刷文字
  • 1: 文字手写, 一般具备明显的书写特征
    +++ char_scores array

字符置信度,值域范围0-1。 设置character=1时输出。

    +++ char_centers array

字符中心点。 设置character=1时输出。

    +++ char_positions array

字符四边形点坐标,以顺时针构成闭合区域。 设置character=1时输出。

    +++ char_candidates array

候选字数组,表示每一个字符的候选,与候选置信度配套使用。 设置character=1时输出。

    +++ char_candidates_score array

候选字置信度数组,表示每一个候选字符的置信度,与候选字符配套使用。 设置character=1时输出。

JSON结构示例

{
    "code": 200,
    "message": "success",
    "version": "v2.0.0",
    "duration": 871.5,
    "result": {
        "angle": 90,
        "width": 1280,
        "height": 1440,
        "lines": [
            {
                "text": "这是一个例子。",
                "score": 0.99,
                "type": "text",
                "position": [
                    0,
                    0,
                    50,
                    0,
                    50,
                    30,
                    0,
                    30
                ],
                "angle": 90,
                "direction": 1,
                "handwritten": 1,
                "char_scores": [
                    0.99,
                    0.98,
                    0.95,
                    0.95,
                    0.99,
                    0.93,
                    0.87
                ],
                "char_centers": [
                    [
                        20,
                        10
                    ],
                    [
                        30,
                        10
                    ],
                    [
                        40,
                        10
                    ],
                    [
                        50,
                        10
                    ],
                    [
                        60,
                        10
                    ],
                    [
                        70,
                        10
                    ],
                    [
                        80,
                        10
                    ]
                ],
                "char_positions": [
                    [
                        18,
                        8,
                        22,
                        8,
                        22,
                        12,
                        18,
                        12
                    ],
                    [
                        28,
                        88,
                        32,
                        8,
                        32,
                        12,
                        28,
                        12
                    ],
                    [
                        38,
                        88,
                        42,
                        8,
                        42,
                        12,
                        38,
                        12
                    ],
                    [
                        48,
                        88,
                        52,
                        8,
                        52,
                        12,
                        48,
                        12
                    ],
                    [
                        58,
                        88,
                        62,
                        8,
                        62,
                        12,
                        58,
                        12
                    ],
                    [
                        68,
                        88,
                        72,
                        8,
                        72,
                        12,
                        68,
                        12
                    ],
                    [
                        78,
                        88,
                        82,
                        8,
                        82,
                        12,
                        78,
                        12
                    ]
                ],
                "char_candidates": [
                    [
                        "这"
                    ],
                    [
                        "是"
                    ],
                    [
                        "一",
                        "-"
                    ],
                    [
                        "个"
                    ],
                    [
                        "例"
                    ],
                    [
                        "子"
                    ],
                    [
                        "。",
                        "O"
                    ]
                ],
                "char_candidates_score": [
                    [
                        0.99
                    ],
                    [
                        0.99
                    ],
                    [
                        0.95,
                        0.05
                    ],
                    [
                        0.99
                    ],
                    [
                        0.99
                    ],
                    [
                        0.99
                    ],
                    [
                        0.89,
                        0.11
                    ]
                ],
                "area_index": 1,
                "area_type": "paragraph",
                "attributes": {
                    "print": 2
                }
            }
        ],
        "areas": [
            {
                "index": 1,
                "score": 0.95,
                "type": "paragraph",
                "position": [
                    0,
                    0,
                    100,
                    0,
                    100,
                    100,
                    0,
                    100
                ],
                "text": "今天天气晴朗,我们可以出去郊游!",
                "attributes": {
                    "print": 1
                }
            }
        ],
        "tables": [
            {
                "position": [
                    0,
                    0,
                    50,
                    0,
                    50,
                    30,
                    0,
                    30
                ],
                "area_index": 1,
                "area_type": "borderless_table",
                "type": "table_with_line",
                "table_rows": 3,
                "table_cols": 4,
                "height_of_rows": [
                    4,
                    5,
                    6
                ],
                "width_of_cols": [
                    20,
                    20,
                    20,
                    20
                ],
                "table_lines": [
                    {
                        "position": [
                            10,
                            20,
                            80,
                            20
                        ],
                        "direction": "horizontal"
                    }
                ],
                "table_cells": [
                    {
                        "start_row": 1,
                        "start_col": 1,
                        "end_row": 2,
                        "end_col": 3,
                        "borders": {
                            "top": 0,
                            "bottom": 0,
                            "left": 1,
                            "right": 1
                        },
                        "text": "单元格里面的文字,若为多行则行间存在换行符。",
                        "position": [
                            0,
                            0,
                            50,
                            0,
                            50,
                            50,
                            0,
                            50
                        ],
                        "lines": [
                            {
                                "text": "这是一个例子。",
                                "score": 0.99,
                                "type": "text",
                                "position": [
                                    0,
                                    0,
                                    50,
                                    0,
                                    50,
                                    30,
                                    0,
                                    30
                                ],
                                "angle": 90,
                                "direction": 1,
                                "handwritten": 1,
                                "char_scores": [
                                    0.99,
                                    0.98,
                                    0.95,
                                    0.95,
                                    0.99,
                                    0.93,
                                    0.87
                                ],
                                "char_centers": [
                                    [
                                        20,
                                        10
                                    ],
                                    [
                                        30,
                                        10
                                    ],
                                    [
                                        40,
                                        10
                                    ],
                                    [
                                        50,
                                        10
                                    ],
                                    [
                                        60,
                                        10
                                    ],
                                    [
                                        70,
                                        10
                                    ],
                                    [
                                        80,
                                        10
                                    ]
                                ],
                                "char_positions": [
                                    [
                                        18,
                                        8,
                                        22,
                                        8,
                                        22,
                                        12,
                                        18,
                                        12
                                    ],
                                    [
                                        28,
                                        88,
                                        32,
                                        8,
                                        32,
                                        12,
                                        28,
                                        12
                                    ],
                                    [
                                        38,
                                        88,
                                        42,
                                        8,
                                        42,
                                        12,
                                        38,
                                        12
                                    ],
                                    [
                                        48,
                                        88,
                                        52,
                                        8,
                                        52,
                                        12,
                                        48,
                                        12
                                    ],
                                    [
                                        58,
                                        88,
                                        62,
                                        8,
                                        62,
                                        12,
                                        58,
                                        12
                                    ],
                                    [
                                        68,
                                        88,
                                        72,
                                        8,
                                        72,
                                        12,
                                        68,
                                        12
                                    ],
                                    [
                                        78,
                                        88,
                                        82,
                                        8,
                                        82,
                                        12,
                                        78,
                                        12
                                    ]
                                ],
                                "char_candidates": [
                                    [
                                        "这"
                                    ],
                                    [
                                        "是"
                                    ],
                                    [
                                        "一",
                                        "-"
                                    ],
                                    [
                                        "个"
                                    ],
                                    [
                                        "例"
                                    ],
                                    [
                                        "子"
                                    ],
                                    [
                                        "。",
                                        "O"
                                    ]
                                ],
                                "char_candidates_score": [
                                    [
                                        0.99
                                    ],
                                    [
                                        0.99
                                    ],
                                    [
                                        0.95,
                                        0.05
                                    ],
                                    [
                                        0.99
                                    ],
                                    [
                                        0.99
                                    ],
                                    [
                                        0.99
                                    ],
                                    [
                                        0.89,
                                        0.11
                                    ]
                                ]
                            }
                        ]
                    }
                ],
                "lines": [
                    {
                        "text": "这是一个例子。",
                        "score": 0.99,
                        "type": "text",
                        "position": [
                            0,
                            0,
                            50,
                            0,
                            50,
                            30,
                            0,
                            30
                        ],
                        "angle": 90,
                        "direction": 1,
                        "handwritten": 1,
                        "char_scores": [
                            0.99,
                            0.98,
                            0.95,
                            0.95,
                            0.99,
                            0.93,
                            0.87
                        ],
                        "char_centers": [
                            [
                                20,
                                10
                            ],
                            [
                                30,
                                10
                            ],
                            [
                                40,
                                10
                            ],
                            [
                                50,
                                10
                            ],
                            [
                                60,
                                10
                            ],
                            [
                                70,
                                10
                            ],
                            [
                                80,
                                10
                            ]
                        ],
                        "char_positions": [
                            [
                                18,
                                8,
                                22,
                                8,
                                22,
                                12,
                                18,
                                12
                            ],
                            [
                                28,
                                88,
                                32,
                                8,
                                32,
                                12,
                                28,
                                12
                            ],
                            [
                                38,
                                88,
                                42,
                                8,
                                42,
                                12,
                                38,
                                12
                            ],
                            [
                                48,
                                88,
                                52,
                                8,
                                52,
                                12,
                                48,
                                12
                            ],
                            [
                                58,
                                88,
                                62,
                                8,
                                62,
                                12,
                                58,
                                12
                            ],
                            [
                                68,
                                88,
                                72,
                                8,
                                72,
                                12,
                                68,
                                12
                            ],
                            [
                                78,
                                88,
                                82,
                                8,
                                82,
                                12,
                                78,
                                12
                            ]
                        ],
                        "char_candidates": [
                            [
                                "这"
                            ],
                            [
                                "是"
                            ],
                            [
                                "一",
                                "-"
                            ],
                            [
                                "个"
                            ],
                            [
                                "例"
                            ],
                            [
                                "子"
                            ],
                            [
                                "。",
                                "O"
                            ]
                        ],
                        "char_candidates_score": [
                            [
                                0.99
                            ],
                            [
                                0.99
                            ],
                            [
                                0.95,
                                0.05
                            ],
                            [
                                0.99
                            ],
                            [
                                0.99
                            ],
                            [
                                0.99
                            ],
                            [
                                0.89,
                                0.11
                            ]
                        ]
                    }
                ]
            }
        ]
    }
}

错误码说明

错误码 描述
40101 x-ti-app-id 或 x-ti-secret-code 为空
40102 x-ti-app-id 或 x-ti-secret-code 无效,验证失败
40103 客户端IP不在白名单
40003 余额不足,请充值后再使用
40004 参数错误,请查看技术文档,检查传参
40007 机器人不存在或未发布
40008 机器人未开通,请至市场开通后重试
40301 图片类型不支持
40302 上传文件大小不符,文件大小不超过 10M
40303 文件类型不支持
40304 图片尺寸不符,图像宽高须介于 20 和 10000(像素)之间
40305 识别文件未上传
30203 基础服务故障,请稍后重试
500 服务器内部错误
官方社群
体验中心

联系我们