RecognizeTableOcr_文字识别_API文档

插件下载了解更多
VS Code 插件
安装插件之前,确保已安装 VS Code安装插件之前,确保已安装 VS Code
Alibaba Cloud Developer Toolkit is a collection of extensions that can help access Alibaba Cloud services in Visual Studio Code.
JetBrains 插件
安装插件之前,确保已安装 JetBrains IDE安装插件之前,确保已安装 JetBrains IDE
The Alibaba Cloud Developer Toolkit for JetBrains makes it easier to access Alibaba Cloud services.

接口说明

本接口适用场景

  • 阿里云表格识别,是阿里云官方自研 OCR 文字识别产品,支持对多种表格格式(有线表格、条纹表格、无线表格)进行智能文字识别并结构化输出识别结果。
  • 阿里云 OCR 产品基于阿里巴巴达摩院强大的 AI 技术及海量数据,历经多年沉淀打磨,具有服务稳定、操作简易、实时性高、能力全面等几大优势。
  • 本接口图片示例

本接口核心能力

分类概述
多格式支持有线表格、条纹表格、无线表格、手写表格识别。
全字段识别智能识别图片上的表格所包含的全部字段。
多类型覆盖支持模糊、光照不均、透视畸变、任意背景等低质量图像识别。
置信度对比对低置信度文字进行标红处理,便于二次确认。

如何使用本接口

步骤概述
1开通 通用文字识别 服务。开通服务前后,您可以通过体验馆免费体验本功能识别效果。
2购买表格识别资源包。本 API 会赠送免费额度,可使用免费额度测试。
3可以参照调试页面提供的代码示例完成 API 接入开发。接入完成后,调用 API 获取识别结果。如果使用子账号调用接口,需要阿里云账号(主账号)对 RAM 账号进行授权。创建 RAM 用户的具体操作,请参考:创建 RAM 用户。文字识别服务提供一种系统授权策略,即 AliyunOCRFullAccess。具体授权操作,请参见在用户页面为 RAM 用户授权。

重要提示

类型概述
图片格式
  • 本接口支持:PNG、JPG、JPEG、BMP、GIF、TIFF、WebP。暂不支持 PDF 格式。
图片尺寸
  • 图片长宽需要大于 15 像素,小于 8192 像素。
  • 长宽比需要小于 50。
  • 如需达到较好识别效果,建议长宽均大于 500px。
  • 图片尺寸过小,会影响识别精度。图片内单字大小在 10-50px 内时,识别效果较好。
图片大小
  • 图片二进制文件不能超过 10MB。
  • 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,且通过传图片 URL 的方式调用接口。
  • 图片尺寸过小,会影响识别精度。图片内单字大小在 10-50px 内时,识别效果较好。
其他提示
  • 接口响应速度和图片中的文字数量有关,如果图片中文字数量越多,接口响应可能越慢。
  • 接口会自动处理反光、扭曲等干扰信息,但会影响精度。请尽量选择清晰度高、无反光、无扭曲的图片。

注:PDF 文件格式的表格解析请点击表格智能解析快速了解

流控信息

当前云产品API请求速率暂未透出。

授权信息

如下是此API对应的授权信息,用于RAM权限策略语句的Action元素中,为RAM用户或RAM角色授予调用此API的权限。请通过 RAM 访问控制设置,使用方法可参考访问控制帮助文档

具体说明如下:展开详情

操作访问级别资源类型条件关键字关联操作
ocr:RecognizeTableOcr
Write
全部资源
*

请求参数

字段名称字段详情
Urlstring
  • 本字段和 body 字段二选一,不可同时透传或同时为空。展开详情
示例值:https://example.png字符长度 <= 2048
bodystring<binary>
  • 本字段和 URL 字段二选一,不可同时透传或同时为空。展开详情
示例值:图片二进制文件
NeedRotateboolean
  • 是否需要自动旋转功能,默认需要。展开详情
示例值:true
LineLessboolean
  • 是否无线条或者只有横线没有竖线,默认有线条。展开详情
示例值:false
SkipDetectionboolean
示例值:false
IsHandWritingstring
示例值:false枚举值:truefalse

返回参数

字段名称字段详情
RequestIdstring

请求唯一 ID

示例值:43A29C77-405E-4CC0-BC55-EE694AD00655
Datastring

返回数据

示例值:{"angle":0,"content":"中学附属初中19~20学年度班级课表三中附中初二39月1日启用星期星期一星期二星期三星期四星期五节次07:40语文数学语文英语历史上108:20喜辉彩霞喜辉刘燕嘉嵩08:30生物地理语文数学语文209:10品青晓明喜辉彩霞喜辉09:20数学政治数学地理数学310:00彩霞艳媚彩霞晓明彩霞10:25物理语文英语语文口语411:05吕学武喜辉刘燕喜辉外教、刘燕11:15英语英语音乐美术英语午511:55刘燕刘燕马丽丽海发刘燕02:30数学物理生物政治体育下603:10彩霞吕学武陈品青艳媚上冲03:25历史信息物理数学物理704:05嘉嵩杨俅吕学武彩霞吕学武04:15班会课活体育体活科活午804:55上冲","height":660,"orgHeight":660,"orgWidth":1026,"prism_tablesInfo":[{"cellInfos":[{"pos":[{"x":0,"y":0},{"x":1017,"y":3},{"x":1020,"y":109},{"x":1,"y":109}],"tableCellId":0,"word":"中学附属初中19~20学年度班级课表三中附中初二39月1日启用","xec":7,"xsc":0,"yec":0,"ysc":0},{"pos":[{"x":1,"y":109},{"x":300,"y":109},{"x":300,"y":169},{"x":1,"y":169}],"tableCellId":1,"word":"星期节次","xec":2,"xsc":0,"yec":1,"ysc":1},{"pos":[{"x":300,"y":109},{"x":444,"y":109},{"x":444,"y":169},{"x":300,"y":169}],"tableCellId":2,"word":"星期一","xec":3,"xsc":3,"yec":1,"ysc":1},{"pos":[{"x":444,"y":109},{"x":588,"y":109},{"x":588,"y":169},{"x":444,"y":169}],"tableCellId":3,"word":"星期二","xec":4,"xsc":4,"yec":1,"ysc":1},{"pos":[{"x":588,"y":109},{"x":732,"y":109},{"x":732,"y":169},{"x":588,"y":169}],"tableCellId":4,"word":"星期三","xec":5,"xsc":5,"yec":1,"ysc":1},{"pos":[{"x":732,"y":109},{"x":876,"y":109},{"x":876,"y":169},{"x":732,"y":169}],"tableCellId":5,"word":"星期四","xec":6,"xsc":6,"yec":1,"ysc":1},{"pos":[{"x":876,"y":109},{"x":1020,"y":109},{"x":1020,"y":169},{"x":876,"y":169}],"tableCellId":6,"word":"星期五","xec":7,"xsc":7,"yec":1,"ysc":1},{"pos":[{"x":1,"y":169},{"x":94,"y":169},{"x":94,"y":469},{"x":1,"y":469}],"tableCellId":7,"word":"上午","xec":0,"xsc":0,"yec":7,"ysc":2},{"pos":[{"x":94,"y":169},{"x":186,"y":169},{"x":186,"y":229},{"x":94,"y":230}],"tableCellId":8,"word":"1","xec":1,"xsc":1,"yec":2,"ysc":2},{"pos":[{"x":186,"y":169},{"x":300,"y":169},{"x":300,"y":229},{"x":186,"y":229}],"tableCellId":9,"word":"07:4008:20","xec":2,"xsc":2,"yec":2,"ysc":2},{"pos":[{"x":300,"y":169},{"x":444,"y":169},{"x":444,"y":229},{"x":300,"y":229}],"tableCellId":10,"word":"语文喜辉","xec":3,"xsc":3,"yec":2,"ysc":2},{"pos":[{"x":444,"y":169},{"x":588,"y":169},{"x":588,"y":229},{"x":444,"y":229}],"tableCellId":11,"word":"数学彩霞","xec":4,"xsc":4,"yec":2,"ysc":2},{"pos":[{"x":588,"y":169},{"x":732,"y":169},{"x":732,"y":229},{"x":588,"y":229}],"tableCellId":12,"word":"语文喜辉","xec":5,"xsc":5,"yec":2,"ysc":2},{"pos":[{"x":732,"y":169},{"x":876,"y":169},{"x":876,"y":229},{"x":732,"y":229}],"tableCellId":13,"word":"英语刘燕","xec":6,"xsc":6,"yec":2,"ysc":2},{"pos":[{"x":876,"y":169},{"x":1020,"y":169},{"x":1020,"y":229},{"x":876,"y":229}],"tableCellId":14,"word":"历史嘉嵩","xec":7,"xsc":7,"yec":2,"ysc":2},{"pos":[{"x":94,"y":230},{"x":186,"y":229},{"x":187,"y":289},{"x":94,"y":290}],"tableCellId":15,"word":"2","xec":1,"xsc":1,"yec":4,"ysc":3},{"pos":[{"x":186,"y":229},{"x":300,"y":229},{"x":299,"y":259},{"x":187,"y":259}],"tableCellId":16,"word":"08:30","xec":2,"xsc":2,"yec":3,"ysc":3},{"pos":[{"x":300,"y":229},{"x":444,"y":229},{"x":444,"y":289},{"x":300,"y":289}],"tableCellId":17,"word":"生物品青","xec":3,"xsc":3,"yec":4,"ysc":3},{"pos":[{"x":444,"y":229},{"x":588,"y":229},{"x":588,"y":289},{"x":444,"y":289}],"tableCellId":18,"word":"地理晓明","xec":4,"xsc":4,"yec":4,"ysc":3},{"pos":[{"x":588,"y":229},{"x":732,"y":229},{"x":732,"y":289},{"x":588,"y":289}],"tableCellId":19,"word":"语文喜辉","xec":5,"xsc":5,"yec":4,"ysc":3},{"pos":[{"x":732,"y":229},{"x":876,"y":229},{"x":876,"y":289},{"x":732,"y":289}],"tableCellId":20,"word":"数学彩霞","xec":6,"xsc":6,"yec":4,"ysc":3},{"pos":[{"x":876,"y":229},{"x":1020,"y":229},{"x":1020,"y":289},{"x":876,"y":289}],"tableCellId":21,"word":"语文喜辉","xec":7,"xsc":7,"yec":4,"ysc":3},{"pos":[{"x":187,"y":259},{"x":299,"y":259},{"x":300,"y":289},{"x":187,"y":289}],"tableCellId":22,"word":"09:10","xec":2,"xsc":2,"yec":4,"ysc":4},{"pos":[{"x":94,"y":290},{"x":187,"y":289},{"x":186,"y":349},{"x":94,"y":350}],"tableCellId":23,"word":"3","xec":1,"xsc":1,"yec":5,"ysc":5},{"pos":[{"x":187,"y":289},{"x":300,"y":289},{"x":300,"y":349},{"x":186,"y":349}],"tableCellId":24,"word":"09:2010:00","xec":2,"xsc":2,"yec":5,"ysc":5},{"pos":[{"x":300,"y":289},{"x":444,"y":289},{"x":444,"y":349},{"x":300,"y":349}],"tableCellId":25,"word":"数学彩霞","xec":3,"xsc":3,"yec":5,"ysc":5},{"pos":[{"x":444,"y":289},{"x":588,"y":289},{"x":588,"y":349},{"x":444,"y":349}],"tableCellId":26,"word":"政治艳媚","xec":4,"xsc":4,"yec":5,"ysc":5},{"pos":[{"x":588,"y":289},{"x":732,"y":289},{"x":732,"y":349},{"x":588,"y":349}],"tableCellId":27,"word":"数学彩霞","xec":5,"xsc":5,"yec":5,"ysc":5},{"pos":[{"x":732,"y":289},{"x":876,"y":289},{"x":876,"y":349},{"x":732,"y":349}],"tableCellId":28,"word":"地理晓明","xec":6,"xsc":6,"yec":5,"ysc":5},{"pos":[{"x":876,"y":289},{"x":1020,"y":289},{"x":1020,"y":349},{"x":876,"y":349}],"tableCellId":29,"word":"数学彩霞","xec":7,"xsc":7,"yec":5,"ysc":5},{"pos":[{"x":94,"y":350},{"x":186,"y":349},{"x":187,"y":409},{"x":94,"y":410}],"tableCellId":30,"word":"4","xec":1,"xsc":1,"yec":6,"ysc":6},{"pos":[{"x":186,"y":349},{"x":300,"y":349},{"x":300,"y":409},{"x":187,"y":409}],"tableCellId":31,"word":"10:2511:05","xec":2,"xsc":2,"yec":6,"ysc":6},{"pos":[{"x":300,"y":349},{"x":444,"y":349},{"x":444,"y":409},{"x":300,"y":409}],"tableCellId":32,"word":"物理吕学武","xec":3,"xsc":3,"yec":6,"ysc":6},{"pos":[{"x":444,"y":349},{"x":588,"y":349},{"x":588,"y":409},{"x":444,"y":409}],"tableCellId":33,"word":"语文喜辉","xec":4,"xsc":4,"yec":6,"ysc":6},{"pos":[{"x":588,"y":349},{"x":732,"y":349},{"x":732,"y":409},{"x":588,"y":409}],"tableCellId":34,"word":"英语刘燕","xec":5,"xsc":5,"yec":6,"ysc":6},{"pos":[{"x":732,"y":349},{"x":876,"y":349},{"x":876,"y":409},{"x":732,"y":409}],"tableCellId":35,"word":"语文喜辉","xec":6,"xsc":6,"yec":6,"ysc":6},{"pos":[{"x":876,"y":349},{"x":1020,"y":349},{"x":1020,"y":409},{"x":876,"y":409}],"tableCellId":36,"word":"口语外教、刘燕","xec":7,"xsc":7,"yec":6,"ysc":6},{"pos":[{"x":94,"y":410},{"x":187,"y":409},{"x":187,"y":469},{"x":94,"y":469}],"tableCellId":37,"word":"5","xec":1,"xsc":1,"yec":7,"ysc":7},{"pos":[{"x":187,"y":409},{"x":300,"y":409},{"x":300,"y":469},{"x":187,"y":469}],"tableCellId":38,"word":"11:1511:55","xec":2,"xsc":2,"yec":7,"ysc":7},{"pos":[{"x":300,"y":409},{"x":444,"y":409},{"x":443,"y":469},{"x":300,"y":469}],"tableCellId":39,"word":"英语刘燕","xec":3,"xsc":3,"yec":7,"ysc":7},{"pos":[{"x":444,"y":409},{"x":588,"y":409},{"x":587,"y":469},{"x":443,"y":469}],"tableCellId":40,"word":"英语刘燕","xec":4,"xsc":4,"yec":7,"ysc":7},{"pos":[{"x":588,"y":409},{"x":732,"y":409},{"x":732,"y":469},{"x":587,"y":469}],"tableCellId":41,"word":"音乐马丽丽","xec":5,"xsc":5,"yec":7,"ysc":7},{"pos":[{"x":732,"y":409},{"x":876,"y":409},{"x":876,"y":469},{"x":732,"y":469}],"tableCellId":42,"word":"美术海发","xec":6,"xsc":6,"yec":7,"ysc":7},{"pos":[{"x":876,"y":409},{"x":1020,"y":409},{"x":1020,"y":469},{"x":876,"y":469}],"tableCellId":43,"word":"英语刘燕","xec":7,"xsc":7,"yec":7,"ysc":7},{"pos":[{"x":1,"y":469},{"x":94,"y":469},{"x":94,"y":649},{"x":1,"y":649}],"tableCellId":44,"word":"下午","xec":0,"xsc":0,"yec":11,"ysc":8},{"pos":[{"x":94,"y":469},{"x":187,"y":469},{"x":187,"y":529},{"x":94,"y":530}],"tableCellId":45,"word":"6","xec":1,"xsc":1,"yec":8,"ysc":8},{"pos":[{"x":187,"y":469},{"x":300,"y":469},{"x":300,"y":529},{"x":187,"y":529}],"tableCellId":46,"word":"02:3003:10","xec":2,"xsc":2,"yec":8,"ysc":8},{"pos":[{"x":300,"y":469},{"x":443,"y":469},{"x":444,"y":529},{"x":300,"y":529}],"tableCellId":47,"word":"数学彩霞","xec":3,"xsc":3,"yec":8,"ysc":8},{"pos":[{"x":443,"y":469},{"x":587,"y":469},{"x":587,"y":529},{"x":444,"y":529}],"tableCellId":48,"word":"物理吕学武","xec":4,"xsc":4,"yec":8,"ysc":8},{"pos":[{"x":587,"y":469},{"x":732,"y":469},{"x":732,"y":529},{"x":587,"y":529}],"tableCellId":49,"word":"生物陈品青","xec":5,"xsc":5,"yec":8,"ysc":8},{"pos":[{"x":732,"y":469},{"x":876,"y":469},{"x":876,"y":529},{"x":732,"y":529}],"tableCellId":50,"word":"政治艳媚","xec":6,"xsc":6,"yec":8,"ysc":8},{"pos":[{"x":876,"y":469},{"x":1020,"y":469},{"x":1020,"y":529},{"x":876,"y":529}],"tableCellId":51,"word":"体育上冲","xec":7,"xsc":7,"yec":8,"ysc":8},{"pos":[{"x":94,"y":530},{"x":187,"y":529},{"x":186,"y":589},{"x":94,"y":590}],"tableCellId":52,"word":"7","xec":1,"xsc":1,"yec":9,"ysc":9},{"pos":[{"x":187,"y":529},{"x":300,"y":529},{"x":300,"y":589},{"x":186,"y":589}],"tableCellId":53,"word":"03:2504:05","xec":2,"xsc":2,"yec":9,"ysc":9},{"pos":[{"x":300,"y":529},{"x":444,"y":529},{"x":444,"y":589},{"x":300,"y":589}],"tableCellId":54,"word":"历史嘉嵩","xec":3,"xsc":3,"yec":9,"ysc":9},{"pos":[{"x":444,"y":529},{"x":587,"y":529},{"x":588,"y":589},{"x":444,"y":589}],"tableCellId":55,"word":"信息杨俅","xec":4,"xsc":4,"yec":9,"ysc":9},{"pos":[{"x":587,"y":529},{"x":732,"y":529},{"x":732,"y":589},{"x":588,"y":589}],"tableCellId":56,"word":"物理吕学武","xec":5,"xsc":5,"yec":9,"ysc":9},{"pos":[{"x":732,"y":529},{"x":876,"y":529},{"x":876,"y":589},{"x":732,"y":589}],"tableCellId":57,"word":"数学彩霞","xec":6,"xsc":6,"yec":9,"ysc":9},{"pos":[{"x":876,"y":529},{"x":1020,"y":529},{"x":1020,"y":589},{"x":876,"y":589}],"tableCellId":58,"word":"物理吕学武","xec":7,"xsc":7,"yec":9,"ysc":9},{"pos":[{"x":94,"y":590},{"x":186,"y":589},{"x":186,"y":649},{"x":94,"y":649}],"tableCellId":59,"word":"8","xec":1,"xsc":1,"yec":11,"ysc":10},{"pos":[{"x":186,"y":589},{"x":300,"y":589},{"x":298,"y":621},{"x":185,"y":620}],"tableCellId":60,"word":"04:15","xec":2,"xsc":2,"yec":10,"ysc":10},{"pos":[{"x":300,"y":589},{"x":444,"y":589},{"x":444,"y":649},{"x":300,"y":649}],"tableCellId":61,"word":"班会","xec":3,"xsc":3,"yec":11,"ysc":10},{"pos":[{"x":444,"y":589},{"x":588,"y":589},{"x":588,"y":649},{"x":444,"y":649}],"tableCellId":62,"word":"课活","xec":4,"xsc":4,"yec":11,"ysc":10},{"pos":[{"x":588,"y":589},{"x":732,"y":589},{"x":732,"y":649},{"x":588,"y":649}],"tableCellId":63,"word":"体育上冲","xec":5,"xsc":5,"yec":11,"ysc":10},{"pos":[{"x":732,"y":589},{"x":876,"y":589},{"x":876,"y":649},{"x":732,"y":649}],"tableCellId":64,"word":"体活","xec":6,"xsc":6,"yec":11,"ysc":10},{"pos":[{"x":876,"y":589},{"x":1020,"y":589},{"x":1020,"y":649},{"x":876,"y":649}],"tableCellId":65,"word":"科活","xec":7,"xsc":7,"yec":11,"ysc":10},{"pos":[{"x":185,"y":620},{"x":298,"y":621},{"x":300,"y":649},{"x":186,"y":649}],"tableCellId":66,"word":"04:55","xec":2,"xsc":2,"yec":11,"ysc":11}],"tableId":0,"xCellSize":8,"yCellSize":12}],"prism_version":"1.0.9","prism_wnum":121,"prism_wordsInfo":[{"angle":-90,"direction":0,"height":398,"pos":[{"x":334,"y":11},{"x":733,"y":10},{"x":733,"y":33},{"x":334,"y":33}],"prob":99,"tableCellId":0,"tableId":0,"width":23,"word":"中学附属初中19~20学年度班级课表","x":522,"y":-177}],"width":1026}
Codestring

错误码(如果识别成功,不会返回此字段)

示例值:unmatchedImageType
Messagestring

错误提示(如果识别成功,不会返回此字段)

示例值:The type of image didn't match the api.

返回说明

返回参数说明


字段类型说明
angleint图片的角度。0 表示正向,90 表示图片朝右,180 朝下,270 朝左。
contentstring识别出图片的文字块汇总。
prism_wordsInfolist文字块信息。
prism_tablesInfolist表格信息。
tableHeadTaillist表头、表尾信息。
prism_wnumint识别的文字块的数量,prism_wordsInfo 数组的大小。
heightint算法矫正图片后的高度。
widthint算法矫正图片后的宽度。
orgHeightint原图的高度。
orgWidthint原图的宽度。

文字块信息(prism_wordsInfo 字段)

字段类型说明
angleint文字块的角度。
heightint文字块的高度(需考虑文字块的角度)
widthint文字块的宽度(需考虑文字块的角度)
poslist文字块的外矩形四个点的坐标按顺时针排列(左上、右上、右下、左下)。当 NeedRotate=true 时,如果最外层的 angle 不为 0,需要按照 angle 矫正图片后,坐标才准确。
wordstring文字块的文字内容。
tableIdint表格的 id(当 OutputTable=true 时并且该文字块在表格内则存在该字段,返回此字段)。
tableCellIdint表格中单元格的 id(当 OutputTable=true 时并且该文字块在表格内则存在该字段,返回此字段)。

表格信息(prism_tablesInfo 字段)

字段类型说明
tableIdint表格 id,和 prism_wordsInfo 信息中的 tableId 对应。
xCellSizeint表格中横坐标单元格的数量。
yCellSizeint表格中纵坐标单元格的数量。
cellInfoslist单元格信息。

单元格信息(cellInfos 字段)

字段类型说明
tableCellIdint表格中单元格 id,和 prism_wordsInfo 信息中的 tableCellId 对应。
wordstring单元格中的文字。
xscintxStartCell 缩写,表示横轴方向该单元格起始在第几个单元格,第一个单元格值为 0。
xecintxEndCell 缩写,表示横轴方向该单元格结束在第几个单元格,第一个单元格值为 0,如果 xsc 和 xec 都为 0 说明该文字在横轴方向占据了一个单元格并且在第一个单元格内。
yscintyStartCell 缩写,表示纵轴方向该单元格起始在第几个单元格,第一个单元格值为 0。
yecintyEndCell 缩写,表示纵轴方向该单元格结束在第几个单元格,第一个单元格值为 0。
poslist单元格位置,按照单元格四个角的坐标顺时针排列,分别为左上 XY 坐标、右上 XY 坐标、右下 XY 坐标、左下 XY 坐标。

表头、表尾信息(tableHeadTail 字段)

字段类型说明
headlist表头信息。
tableIdint表格 ID(和prism_tablesInfo中的 tableId 对应)。
taillist表尾信息。

返回示例

变更历史

变更时间变更内容概要操作
2023-03-22
变更请求参数IsHandWriting
删除返回参数
2022-11-15
变更请求参数Url
2021-08-17
变更请求参数Url
新增请求参数body

相关示例