本文档介绍表格识别RecognizeTable的语法及示例。
功能描述
RecognizeTable可以自动识别表格位置、表格内容信息。适用于黑色的,横线、竖线都齐全的表格中内容识别。
前提条件
输入限制
- 请求格式:JPEG、JPG、PNG、BMP、GIF。
- 图像大小:图像大小不超过3M。
- 图像分辨率:不限制图片分辨率,但图片分辨率太高可能会导致API识别超时,超时时间为5秒。
- URL地址中不能包含中文字符。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | RecognizeTable |
要执行的操作。取值:RecognizeTable。 |
AssureDirection | Boolean | 是 | false |
图片方向是否确定为正向。
|
HasLine | Boolean | 是 | false |
是否无线条。
|
ImageURL | String | 是 | https://viapi-demo.oss-cn-shanghai-internal.aliyuncs.com/viapi-demo/images/RecognizeTable/%E8%A1%A8%E6%A0%BC.jpg |
图片URL地址。当前仅支持上海地域的OSS链接,如何生成URL请参见生成URL。 |
OutputFormat | String | 是 | json |
输出格式。包括:html、json、xlsx。 |
SkipDetection | Boolean | 是 | false |
是否跳过检测,取值true或false。 |
UseFinanceModel | Boolean | 是 | true |
是否使用财务报表模型。取值true或false。 |
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
Data | Struct |
返回的结果数据内容。 |
|
FileContent | String | - |
HTML字符串。 |
Tables | Array of Table |
JSON格式的数据。 |
|
Head | List | 14 淮南矿 PPN003 |
表头信息。 |
TableRows | Array of TableRow |
JSON格式的表格数据。 |
|
TableColumns | Array of TableColumn |
JSON格式的表格数据。 |
|
EndColumn | Integer | 1 |
单元格所占的列数(colspan)为ex-sx。 |
EndRow | Integer | 1 |
单元格所占的行数(rowspan)为ey-sy。 |
Height | Integer | 0 |
图片上单元格的高度。 |
StartColumn | Integer | 0 |
单元格的起始列ID。 |
StartRow | Integer | 0 |
单元格的起始行ID。 |
Texts | List | 项目 |
文本,每行(row)文字为一个block。 |
Width | Integer | 0 |
图片上单元格的宽度。 |
Tail | List | 职工券 |
表尾信息。 |
RequestId | String | ECC70342-7CF1-4EC9-AE5A-41923D10D552 |
请求ID。 |
示例
请求示例
http(s)://ocr.cn-shanghai.aliyuncs.com/?Action=RecognizeTable
&AssureDirection=false
&HasLine=false
&ImageURL=https://viapi-demo.oss-cn-shanghai-internal.aliyuncs.com/viapi-demo/images/RecognizeTable/%E8%A1%A8%E6%A0%BC.jpg
&OutputFormat=json
&SkipDetection=false
&UseFinanceModel=true
&<公共请求参数>
正常返回示例
XML
格式
<RequestId>ECC70342-7CF1-4EC9-AE5A-41923D10D552</RequestId>
<Data>
<Tables>
<Head>14 淮南矿 PPN003</Head>
<Head>14 淮南矿 PPN004</Head>
<Head>14 淮南矿 MTNO01</Head>
<Head>15淮南矿PPN001</Head>
<Tail>15 淮南矿 PPNO02</Tail>
<Tail>15淮南矿PPN003</Tail>
<Tail>12芜湖港</Tail>
<Tail>职工券</Tail>
<TableRows>
<TableColumns>
<EndRow>1</EndRow>
<EndColumn>1</EndColumn>
<Texts>项目</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>0</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>1</EndRow>
<EndColumn>2</EndColumn>
<Texts>目</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>0</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>1</EndRow>
<EndColumn>3</EndColumn>
<Texts>年末余额</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>0</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>1</EndRow>
<EndColumn>4</EndColumn>
<Texts>年初余额</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>0</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>2</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>1</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>2</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>1</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>2</EndRow>
<EndColumn>3</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>1</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>2</EndRow>
<EndColumn>4</EndColumn>
<Texts>1,993,528,348.75</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>1</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>3</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>2</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>3</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>2</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>3</EndRow>
<EndColumn>3</EndColumn>
<Texts>298,063,697.36</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>2</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>3</EndRow>
<EndColumn>4</EndColumn>
<Texts>3,987,056,697.49</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>2</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>4</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>3</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>4</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>3</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>4</EndRow>
<EndColumn>3</EndColumn>
<Texts>2,989,029,381.93</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>3</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>4</EndRow>
<EndColumn>4</EndColumn>
<Texts>297,152,184.91</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>3</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>5</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>4</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>5</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>4</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>5</EndRow>
<EndColumn>3</EndColumn>
<Texts>1,991,116,621.19</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>4</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>5</EndRow>
<EndColumn>4</EndColumn>
<Texts>2,979,665,189.68</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>4</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>6</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>5</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>6</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>5</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>6</EndRow>
<EndColumn>3</EndColumn>
<Texts>994,500,600.03</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>5</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>6</EndRow>
<EndColumn>4</EndColumn>
<Texts>1,984,968,998.90</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>5</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>7</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>6</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>7</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>6</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>7</EndRow>
<EndColumn>3</EndColumn>
<Texts>1,494,278,418.49</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>6</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>7</EndRow>
<EndColumn>4</EndColumn>
<Texts>991,495,233.24</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>6</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>8</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>7</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>8</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>7</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>8</EndRow>
<EndColumn>3</EndColumn>
<Texts>789,105,219.30</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>7</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>8</EndRow>
<EndColumn>4</EndColumn>
<Texts>1,496,800,438.30</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>7</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>9</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>8</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>9</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>8</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>9</EndRow>
<EndColumn>3</EndColumn>
<Texts>61,590.70</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>8</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>9</EndRow>
<EndColumn>4</EndColumn>
<Texts>61,590.70</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>8</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
<TableRows>
<TableColumns>
<EndRow>10</EndRow>
<EndColumn>1</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>9</StartRow>
<StartColumn>0</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>10</EndRow>
<EndColumn>2</EndColumn>
<Height>0</Height>
<Width>0</Width>
<StartRow>9</StartRow>
<StartColumn>1</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>10</EndRow>
<EndColumn>3</EndColumn>
<Texts>10,551,553,801.53</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>9</StartRow>
<StartColumn>2</StartColumn>
</TableColumns>
<TableColumns>
<EndRow>10</EndRow>
<EndColumn>4</EndColumn>
<Texts>18,618,966,233.02</Texts>
<Height>0</Height>
<Width>0</Width>
<StartRow>9</StartRow>
<StartColumn>3</StartColumn>
</TableColumns>
</TableRows>
</Tables>
</Data>
JSON
格式
{
"RequestId": "ECC70342-7CF1-4EC9-AE5A-41923D10D552",
"Data": {
"Tables": [
{
"Head": [
"14 淮南矿 PPN003",
"14 淮南矿 PPN004",
"14 淮南矿 MTNO01",
"15淮南矿PPN001"
],
"Tail": [
"15 淮南矿 PPNO02",
"15淮南矿PPN003",
"12芜湖港",
"职工券"
],
"TableRows": [
{
"TableColumns": [
{
"EndRow": 1,
"EndColumn": 1,
"Texts": [
"项目"
],
"Height": 0,
"Width": 0,
"StartRow": 0,
"StartColumn": 0
},
{
"EndRow": 1,
"EndColumn": 2,
"Texts": [
"目"
],
"Height": 0,
"Width": 0,
"StartRow": 0,
"StartColumn": 1
},
{
"EndRow": 1,
"EndColumn": 3,
"Texts": [
"年末余额"
],
"Height": 0,
"Width": 0,
"StartRow": 0,
"StartColumn": 2
},
{
"EndRow": 1,
"EndColumn": 4,
"Texts": [
"年初余额"
],
"Height": 0,
"Width": 0,
"StartRow": 0,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 2,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 1,
"StartColumn": 0
},
{
"EndRow": 2,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 1,
"StartColumn": 1
},
{
"EndRow": 2,
"EndColumn": 3,
"Height": 0,
"Width": 0,
"StartRow": 1,
"StartColumn": 2
},
{
"EndRow": 2,
"EndColumn": 4,
"Texts": [
"1,993,528,348.75"
],
"Height": 0,
"Width": 0,
"StartRow": 1,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 3,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 2,
"StartColumn": 0
},
{
"EndRow": 3,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 2,
"StartColumn": 1
},
{
"EndRow": 3,
"EndColumn": 3,
"Texts": [
"298,063,697.36"
],
"Height": 0,
"Width": 0,
"StartRow": 2,
"StartColumn": 2
},
{
"EndRow": 3,
"EndColumn": 4,
"Texts": [
"3,987,056,697.49"
],
"Height": 0,
"Width": 0,
"StartRow": 2,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 4,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 3,
"StartColumn": 0
},
{
"EndRow": 4,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 3,
"StartColumn": 1
},
{
"EndRow": 4,
"EndColumn": 3,
"Texts": [
"2,989,029,381.93"
],
"Height": 0,
"Width": 0,
"StartRow": 3,
"StartColumn": 2
},
{
"EndRow": 4,
"EndColumn": 4,
"Texts": [
"297,152,184.91"
],
"Height": 0,
"Width": 0,
"StartRow": 3,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 5,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 4,
"StartColumn": 0
},
{
"EndRow": 5,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 4,
"StartColumn": 1
},
{
"EndRow": 5,
"EndColumn": 3,
"Texts": [
"1,991,116,621.19"
],
"Height": 0,
"Width": 0,
"StartRow": 4,
"StartColumn": 2
},
{
"EndRow": 5,
"EndColumn": 4,
"Texts": [
"2,979,665,189.68"
],
"Height": 0,
"Width": 0,
"StartRow": 4,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 6,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 5,
"StartColumn": 0
},
{
"EndRow": 6,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 5,
"StartColumn": 1
},
{
"EndRow": 6,
"EndColumn": 3,
"Texts": [
"994,500,600.03"
],
"Height": 0,
"Width": 0,
"StartRow": 5,
"StartColumn": 2
},
{
"EndRow": 6,
"EndColumn": 4,
"Texts": [
"1,984,968,998.90"
],
"Height": 0,
"Width": 0,
"StartRow": 5,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 7,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 6,
"StartColumn": 0
},
{
"EndRow": 7,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 6,
"StartColumn": 1
},
{
"EndRow": 7,
"EndColumn": 3,
"Texts": [
"1,494,278,418.49"
],
"Height": 0,
"Width": 0,
"StartRow": 6,
"StartColumn": 2
},
{
"EndRow": 7,
"EndColumn": 4,
"Texts": [
"991,495,233.24"
],
"Height": 0,
"Width": 0,
"StartRow": 6,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 8,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 7,
"StartColumn": 0
},
{
"EndRow": 8,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 7,
"StartColumn": 1
},
{
"EndRow": 8,
"EndColumn": 3,
"Texts": [
"789,105,219.30"
],
"Height": 0,
"Width": 0,
"StartRow": 7,
"StartColumn": 2
},
{
"EndRow": 8,
"EndColumn": 4,
"Texts": [
"1,496,800,438.30"
],
"Height": 0,
"Width": 0,
"StartRow": 7,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 9,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 8,
"StartColumn": 0
},
{
"EndRow": 9,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 8,
"StartColumn": 1
},
{
"EndRow": 9,
"EndColumn": 3,
"Texts": [
"61,590.70"
],
"Height": 0,
"Width": 0,
"StartRow": 8,
"StartColumn": 2
},
{
"EndRow": 9,
"EndColumn": 4,
"Texts": [
"61,590.70"
],
"Height": 0,
"Width": 0,
"StartRow": 8,
"StartColumn": 3
}
]
},
{
"TableColumns": [
{
"EndRow": 10,
"EndColumn": 1,
"Height": 0,
"Width": 0,
"StartRow": 9,
"StartColumn": 0
},
{
"EndRow": 10,
"EndColumn": 2,
"Height": 0,
"Width": 0,
"StartRow": 9,
"StartColumn": 1
},
{
"EndRow": 10,
"EndColumn": 3,
"Texts": [
"10,551,553,801.53"
],
"Height": 0,
"Width": 0,
"StartRow": 9,
"StartColumn": 2
},
{
"EndRow": 10,
"EndColumn": 4,
"Texts": [
"18,618,966,233.02"
],
"Height": 0,
"Width": 0,
"StartRow": 9,
"StartColumn": 3
}
]
}
]
}
]
}
}
错误码
关于表格识别的错误码,详情请参见常见错误码。
SDK参考
阿里云视觉AI能力支持使用SDK调用,具体可参见SDK总览下载安装。
安全声明
- 请确保上传的图片或文件来源符合相应的法律法规。
- 通过体验调试上传的临时文件有效期为1小时,在24小时后会被系统自动清理删除。
在文档使用中是否遇到以下问题
更多建议
匿名提交