我正在使用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
唯一可靠的方法是启用 hOCR 输出并对其进行解析。它将包含页面上每个单词的位置(以像素为单位),就像在原始图像中一样。
您可以通过tessedit_create_hocr 1在 Tesseract 的配置文件或您使用的任何 API 中指定来实现。
hOCR 是 HTML 的一个子集,而 Tesseract 生成的并不总是有效的 XML,因此您可以使用 HTML 解析器或编写自己的解析器,但您不能可靠地使用 XML 解析器。
| 归档时间: | 
 | 
| 查看次数: | 12865 次 | 
| 最近记录: |