本文介紹文字識別(ocr)類目下的表格識別RecognizeTable的語法及示例。

功能描述

表格識別能力可以自動識別表格內容信息。適用于邊框線條為黑色、橫豎框線齊全的表格中內容識別。

說明
  • 您可以進入在線咨詢獲取在線人工幫助。
  • 當前能力可在視覺智能開放平臺有完整的免費產品體驗,您可以單擊立即試用對該能力進行更直觀試用以及在線購買。
  • 阿里云視覺智能開放平臺視覺AI能力API接入、接口使用或問題咨詢等,請通過釘釘群(23109592)加入阿里云視覺智能開放平臺咨詢群聯系我們。

接入指引

1. 注冊阿里云賬號:打開阿里云官網,在阿里云官網右上角,單擊立即注冊,按照操作提示完成賬號注冊。

2. 開通能力:請確保您已開通文字識別服務,若未開通服務請立即開通

3. 創(chuàng)建AccessKey:請確保您已創(chuàng)建AccessKey,如果您使用的是子賬號AccessKey,您需要給子賬號賦予AliyunVIAPIFullAccess權限,具體操作,請參見RAM授權

4. 在線調試(可選):您可以通過OpenAPI Explorer在線調試能力,查看完整的調用示例代碼及SDK依賴信息,也可以下載完整的工程。

5. 開發(fā)接入步驟:

  • SDK總覽中選擇您要接入使用的SDK語言。
  • 在對應語言的SDK文檔中找到AI類目為文字識別(ocr)的SDK包進行安裝。
  • 參考文檔中提供的示例代碼進行適當修改后調用。

6. 示例代碼:該能力常用語言的示例代碼,請參見表格識別示例代碼

7. 客戶端直接調用:該能力常用的客戶端調用方式包括以下幾種。

輸入限制

  • 圖像格式:JPEG、JPG、PNG、BMP、GIF。
  • 圖像大小:不超過3 MB。
  • 圖像分辨率:不限制圖片分辨率,但圖片分辨率太高可能會導致API識別超時,超時時間為5秒。
  • URL地址中不能包含中文字符。

計費說明

關于表格識別的計費方式及報價,請參見計費介紹

說明 下方調試接口為付費接口,如需免費體驗調試請前往體驗中心

調試

您可以在OpenAPI Explorer中直接運行該接口,免去您計算簽名的困擾。運行成功后,OpenAPI Explorer可以自動生成SDK代碼示例。

請求參數

名稱 類型 是否必選 示例值 描述
Action String RecognizeTable

系統規(guī)定參數。取值:RecognizeTable

ImageURL String http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTable/RecognizeTable4.jpg

圖像URL地址。推薦使用上海地域的OSS鏈接,對于文件在本地或者非上海地域OSS鏈接的情況,請參見文件URL處理

OutputFormat String json

輸出格式為json。(htmlxlsx已廢棄,當選擇htmlxlsx入參,最終輸出也為JSON格式。)

UseFinanceModel Boolean true

是否使用財務報表模型。

  • true:財務報表模型
  • false:非財務報表模型
AssureDirection Boolean false

圖像方向是否確定為正向。

  • true:正向
  • false:反向
HasLine Boolean false

是否無線條。

  • true:無線條或者只有橫線沒有豎線
  • false:有線條
SkipDetection Boolean false

是否跳過檢測。

  • true:跳過檢查
  • false:不跳過檢查

返回數據

名稱 類型 示例值 描述
RequestId String CBC36BE6-2A18-5256-82BD-8B5477E5D058

請求ID。

Data Object

返回的結果數據內容。

FileContent String UEsDBBQAAAAIAAAAIQBukMk4WAIAA****

請求參數htmlxlsx已廢棄,默認輸出JSON格式的數據。

Tables Array of Table

JSON格式的數據。僅在請求參數OutputFormat為json時顯示。

Head Array of String 存活盤點表

表頭信息。

Tail Array of String 職工券

表尾信息。

TableRows Array of TableRow

JSON格式的表格數據。

TableColumns Array of TableColumn

JSON格式的表格數據。

EndRow Integer 1

單元格所占的行數(rowspan)為ey-sy。

EndColumn Integer 4

單元格所占的列數(colspan)為ex-sx。

Width Integer 0

圖片上單元格的寬度。

Height Integer 0

圖片上單元格的高度。

Texts Array of String 序號

文本,每行(row)文字為一個block。

StartRow Integer 0

單元格的起始行ID。

StartColumn Integer 1

單元格的起始列ID。

SDK參考

阿里云視覺AI文字識別類目下的表格識別能力推薦使用SDK調用,支持多種編程語言,調用時請選擇AI類目為文字識別(ocr)的SDK包,文件參數通過SDK調用可支持本地文件及任意URL,具體可參見SDK總覽

示例代碼

該能力常用語言的示例代碼,請參見表格識別示例代碼

示例

請求示例

http(s)://ocr.cn-shanghai.aliyuncs.com/?Action=RecognizeTable      //更多關于訪問域名(Endpoint)信息,請參見:http://m.bestwisewords.com/document_detail/143103.html
&ImageURL=http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeTable/RecognizeTable4.jpg
&OutputFormat=json
&UseFinanceModel=true
&AssureDirection=false
&HasLine=false
&SkipDetection=false
&公共請求參數

正常返回示例

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "CBC36BE6-2A18-5256-82BD-8B5477E5D058",
  "Data" : {
    "Tables" : {
      "Head" : "存活盤點表",
      "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
        }, {
          "EndRow" : 1,
          "EndColumn" : 5,
          "Texts" : "單價",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 0,
          "StartColumn" : 4
        }, {
          "EndRow" : 1,
          "EndColumn" : 6,
          "Texts" : "賬面金額",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 0,
          "StartColumn" : 5
        }, {
          "EndRow" : 1,
          "EndColumn" : 7,
          "Texts" : "備注",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 0,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 2,
          "EndColumn" : 1,
          "Texts" : 1,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 0
        }, {
          "EndRow" : 2,
          "EndColumn" : 2,
          "Texts" : "發(fā)電機",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 1
        }, {
          "EndRow" : 2,
          "EndColumn" : 3,
          "Texts" : "臺",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 2
        }, {
          "EndRow" : 2,
          "EndColumn" : 4,
          "Texts" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 3
        }, {
          "EndRow" : 2,
          "EndColumn" : 5,
          "Texts" : "499,222,12",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 4
        }, {
          "EndRow" : 2,
          "EndColumn" : 6,
          "Texts" : 99844424,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 5
        }, {
          "EndRow" : 2,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 1,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 3,
          "EndColumn" : 1,
          "Texts" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 0
        }, {
          "EndRow" : 3,
          "EndColumn" : 2,
          "Texts" : "變壓器",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 1
        }, {
          "EndRow" : 3,
          "EndColumn" : 3,
          "Texts" : "臺",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 2
        }, {
          "EndRow" : 3,
          "EndColumn" : 4,
          "Texts" : 1,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 3
        }, {
          "EndRow" : 3,
          "EndColumn" : 5,
          "Texts" : "205,121,18",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 4
        }, {
          "EndRow" : 3,
          "EndColumn" : 6,
          "Texts" : "205,121,18",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 5
        }, {
          "EndRow" : 3,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 2,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 4,
          "EndColumn" : 1,
          "Texts" : 3,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 0
        }, {
          "EndRow" : 4,
          "EndColumn" : 2,
          "Texts" : "豆?jié){生產線",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 1
        }, {
          "EndRow" : 4,
          "EndColumn" : 3,
          "Texts" : "臺",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 2
        }, {
          "EndRow" : 4,
          "EndColumn" : 4,
          "Texts" : 1,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 3
        }, {
          "EndRow" : 4,
          "EndColumn" : 5,
          "Texts" : "123,987,23",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 4
        }, {
          "EndRow" : 4,
          "EndColumn" : 6,
          "Texts" : "123,987,23",
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 5
        }, {
          "EndRow" : 4,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 3,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 5,
          "EndColumn" : 1,
          "Texts" : 4,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 0
        }, {
          "EndRow" : 5,
          "EndColumn" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 1
        }, {
          "EndRow" : 5,
          "EndColumn" : 3,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 2
        }, {
          "EndRow" : 5,
          "EndColumn" : 4,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 3
        }, {
          "EndRow" : 5,
          "EndColumn" : 5,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 4
        }, {
          "EndRow" : 5,
          "EndColumn" : 6,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 5
        }, {
          "EndRow" : 5,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 4,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 6,
          "EndColumn" : 1,
          "Texts" : 5,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 0
        }, {
          "EndRow" : 6,
          "EndColumn" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 1
        }, {
          "EndRow" : 6,
          "EndColumn" : 3,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 2
        }, {
          "EndRow" : 6,
          "EndColumn" : 4,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 3
        }, {
          "EndRow" : 6,
          "EndColumn" : 5,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 4
        }, {
          "EndRow" : 6,
          "EndColumn" : 6,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 5
        }, {
          "EndRow" : 6,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 5,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 7,
          "EndColumn" : 1,
          "Texts" : 6,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 0
        }, {
          "EndRow" : 7,
          "EndColumn" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 1
        }, {
          "EndRow" : 7,
          "EndColumn" : 3,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 2
        }, {
          "EndRow" : 7,
          "EndColumn" : 4,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 3
        }, {
          "EndRow" : 7,
          "EndColumn" : 5,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 4
        }, {
          "EndRow" : 7,
          "EndColumn" : 6,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 5
        }, {
          "EndRow" : 7,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 6,
          "StartColumn" : 6
        } ]
      }, {
        "TableColumns" : [ {
          "EndRow" : 8,
          "EndColumn" : 1,
          "Texts" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 0
        }, {
          "EndRow" : 8,
          "EndColumn" : 2,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 1
        }, {
          "EndRow" : 8,
          "EndColumn" : 3,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 2
        }, {
          "EndRow" : 8,
          "EndColumn" : 4,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 3
        }, {
          "EndRow" : 8,
          "EndColumn" : 5,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 4
        }, {
          "EndRow" : 8,
          "EndColumn" : 6,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 5
        }, {
          "EndRow" : 8,
          "EndColumn" : 7,
          "Height" : 0,
          "Width" : 0,
          "StartRow" : 7,
          "StartColumn" : 6
        } ]
      } ]
    }
  }
}

錯誤碼

關于表格識別的錯誤碼,詳情請參見常見錯誤碼

安全聲明

  • 請確保上傳的圖片或文件來源符合相應的法律法規(guī)。
  • 通過體驗調試上傳的臨時文件有效期為1小時,在24小時后會被系統自動清理刪除。