【问题标题】:Table detection using tesseract api使用 tesseract api 进行表检测
【发布时间】:2017-12-07 10:10:39
【问题描述】:

有没有什么办法使用tesseract ocr检测表。

我正在使用以下 c# 代码 (charlesw/tesseract)

using (var iter = page.GetIterator())
{
    iter.Begin();
    do
    {
        var blockType = iter.BlockType; // Never equals to Table

    } while (iter.Next(PageIteratorLevel.Word));
}

遍历块并查询BlockType 属性,但它永远不会返回PolyBlockType.Table 值,即使我的文档中有表格

我也尝试将“textord_tabfind_find_tables”变量设置为 true,但没有成功。

【问题讨论】:

标签: c# ocr tesseract


【解决方案1】:

我只能找到 PSM 1、2、3、4 的表;这对我来说是一把钥匙。

我无法在我的所有文档中找到表格,因此我在 Google Doc 中制作了一个(带有一些其他文本)和两个表格,并导出为 PDF,然后转换为 300 和 600 dpi 的 PNG。它能够找到我的全角表格,但不能找到我的半角表格。

使用 tesserocr Python 绑定:

ret = api.SetVariable('textord_tabfind_find_tables', 'true')  # 400: 1
ret = api.SetVariable('textord_tablefind_recognize_tables', 'true') # 400: 0
ret = api.SetVariable('textord_tablefind_show_mark', 'true')  # 400: 0
ret = api.SetVariable('textord_tablefind_show_stats', 'true')   # 400: 0

if args.scrollview:
    api.SetVariable("textord_show_tables", "true")  # launches ScrollView

api.Recognize()
level = RIL.BLOCK           # BLOCK, PARA, SYMBOL, TEXTLINE, WORD
riter = api.GetIterator()
for r in iterate_level(riter, level):
    if args.tablesonly is False or PT_NAME[r.BlockType()] == 'TABLE':
        print('### blocktype={}={} confidence={} txt:\n{}'.format(
            r.BlockType(), PT_NAME[r.BlockType()],
            int(r.Confidence(level)), r.GetUTF8Text(level)))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-09
    • 2021-08-07
    • 2013-05-31
    • 2019-03-12
    • 2019-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多