我正在使用 tesseract ocr 从图像中提取文本。保留文档的结构对我来说非常重要。目前,tesseract 不保留结构,事实上它改变了文本的顺序。我的输入是下图。
我得到的输出如下:
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/