【问题标题】:how to generate one input.tif per document in tesseract-ocr?如何在 tesseract-ocr 中为每个文档生成一个 input.tif?
【发布时间】:2019-09-23 18:27:08
【问题描述】:

我发现了如何让 tesseract 输出它用于 OCR 的 tif。但是,此 tif 始终称为 tessinput.tif,如果我在一个文件夹中有多个文档,那么只会显示最后创建的 tessinput.tif。多层 tif 也是如此。

有没有办法让 tesseract 为文件夹中的每个文档输出其输入 tif 文件,例如。 G。通过将 _1 附加到其名称或其他内容?

编辑

好吧,到目前为止我已经添加了tessedit_write_images=1 配置参数。哪个,你瞧,输出 tessinput.tif ......但我不知道,如果你能以某种方式更改该文件的名称

【问题讨论】:

标签: tesseract


【解决方案1】:

输出tessinput.tif后,等待文件写入,然后重命名,处理下一张图片。

【讨论】:

    【解决方案2】:

    我使用 Tesseract (4.0) 识别单个图像中的多行字符。在这里,我建议一种简化的方法,以适当的格式保存所有 tessinput.tif 文件,然后仔细检查输出:

    import os
    import pytesseract
    
    config = '-l eng --oem 3 --psm 7 --dpi 600 -c tessedit_write_images=true'
    
    '''
    in my use case, I extracted lines contours from the image, stored coordinates for
    each line before reading the line with tesseract. Here I provide a simplified
    solution with a list of 3 images, just for the example
    '''
    
    img = ['img1.png', 'img2.png', 'img3.png']     
    
    for i in range(len(image)):
        pytesseract.image_to_string(img[i], config=config)
        os.system('mv tessinput.tif tessinput_{:03d}.tif'.format(i))
    

    【讨论】:

      猜你喜欢
      • 2015-10-17
      • 2014-09-21
      • 1970-01-01
      • 2019-10-30
      • 1970-01-01
      • 1970-01-01
      • 2022-01-26
      • 2020-06-17
      • 2015-09-10
      相关资源
      最近更新 更多