ocr - 如何在 tesseract 中保留文档结构

标签 ocr tesseract

我正在使用 tesseract ocr 从图像中提取文本。保留文档的结构对我来说非常重要。目前,tesseract 不保留结构,事实上它改变了文本的顺序。我的输入是下图。

input

我得到的输出如下:

Someto the left
Someto the left

Some in the middle
Some in the middle

Some with some tab
Some with some tab

Some with some space between them
Some with some space between them

Sometext here
Sometext here

this much
this much

如何获得图像中相同结构的所需输出?

即如下:

                                                 Some text here
                                                 Some text here

Some to the left
Some to the left

                    Some in the middle
                    Some in the middle

        Some with some tab
        Some with some tab

Some with some space between them                       this much
Some with some space between them                       this much

最佳答案

较新版本的 tesseract (3.04) 有一个名为 preserve_interword_spaces 的选项,它应该可以满足您的需求。

请注意,tesseract 检测到的单词之间的空格数量在相似的行之间可能并不总是相同。因此,与前面的一系列空格左对齐的单词(如您的示例中所示)可能不会以这种方式输出 - preserve_interword_spaces 选项不会尝试做任何花哨的事情,它只是保留发现空格提取。默认情况下,超立方体将一系列空间折叠成一个。

有关此选项的详细信息是 here .

关于ocr - 如何在 tesseract 中保留文档结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22609778/

相关文章:

c++ - 如何将所有依赖项和共享库编译成一个二进制文件

open-source - 中文开源OCR

parallel-processing - Tesseract 如何使用 OpenCL?

Java/Tesseract-OCR : Unsatisfied LinkError libtesseract302

python-3.x - Pytesseract 混淆了零 ('0' )和大写 O ('O' )

c# - 如何OCR雕刻文字?

android - OCR 使用 tess-two 库返回不正确的文本

android-studio - 错误 :Configuration with name 'default' not found in Android Studio

iOS Tesseract OCR 图片准备

python - 使用 Tesseract OCR 4.x 保留缩进