阿里云人工智能图像类表格识别

表格识别

调用地址:https://form.market.alicloudapi.com/api/predict/ocr_table_parse
云市场文档页面:https://market.aliyun.com/products/57124001/cmapi024968.html

适用场景:线条为黑色的,横线和竖线都齐全的表格识别,如:财务报表(请用finance模型);房产证等;

输入格式

  1. 输入:
  2. {
  3. "image": "图片二进制数据的base64编码",
  4. "configure": "{\"format\":\"html\", \"finance\":false, \"dir_assure\":false, "\line_less\":false}"
  5. }
  6. 参数说明:
  7. 1. format 输出格式:html/json/xlsx;
  8. 2. finance 是否使用财务报表模型: true/false;
  9. 3. dir_assure 图片方向是否确定是正向的: true(确定)/false(不确定)
  10. 4. line_less:是否无线条: true(无线条,或者只有横线没有竖线)/false(有线条)

输出格式

  1. 支持三种格式输出:html/xlsx(excel)/json
  2. #html 格式输出
  3. {
  4. "success":true,
  5. "tables":"<html>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n<style type=\"text/css\">\n table tr td { border: 1px solid blue }\n table { border: 1px solid blue }\n span.note { font-size: 9px; color: red }\n</style>\n<table \"id\"=0>\n<tr><td colspan=1 rowspan=1>项 目 </td><td colspan=1 rowspan=1>期末余额 </td><td colspan=1 rowspan=1>年初余额 </td></tr><tr><td colspan=1 rowspan=1>合计 </td><td colspan=1 rowspan=1>5,423,591,988.10 </td><td colspan=1 rowspan=1>4,281,407,583.62 </td></tr>...</table></html>\n"
  6. }
  7. #xlsx 格式:
  8. {"success":true,
  9. "tables":"UEsDBBQAAAAIAAAAIQAR0e9YNAoAAIpUAAAYAAAA..." #base64 encoded excel file( base64编码的excel文件)
  10. }
  11. 直接拷贝tables后面的字符串到文件保存,需要将里面的\n替换掉,在linux环境下,可以执行如下操作:
  12. sed -i -e 's/\\n/\n/g' tmp_base64
  13. base64 -d tmp_base64 > 9_100.xlsx
  14. #json 格式输出
  15. {
  16. "success":true,
  17. "tables":[
  18. [ #table 0
  19. [ # table0 row 0
  20. { # table 0 row 0 col 0
  21. "sx":0, #start from column(单元格的起始列id)
  22. "sy":0, #start row(单元格的起始行id)
  23. "ex":1, #one past end column index(单元格所占的列数(colspan)为ex - sx)
  24. "ey":1, #one past end row index(单元格所占的行数(rowspan)为ey - sy)
  25. "height":96, #cell height,图片上单元格的高度
  26. "width":573 #cell width,图片上单元格的宽度
  27. "text":[
  28. "项", #text block 0 (第一个文字块)
  29. "目" #text block 1 (第二个文字块)
  30. ],
  31. },
  32. ...
  33. ],
  34. [ #table 0 row 1
  35. {
  36. "ex":1,
  37. "ey":2,
  38. "height":94,
  39. "sx":0,
  40. "sy":1,
  41. "text":[
  42. "合计"
  43. ],
  44. "width":572
  45. },
  46. ...
  47. ],
  48. ... #more rows
  49. ]
  50. ]
  51. }

原创文章,作者:网友投稿,如若转载,请注明出处:https://www.cloudads.cn/archives/33607.html

发表评论

登录后才能评论