Pytesseract和图像.tif文件



我需要转录一张图像.tif其中有几页使用 pytesseract 的文本。 我有下一个代码:

> From PIL import Image
> Import pytesseract
> Pytesseract.pytesseract.tesseract_cmd = 'C: / Program Files (x86) / Tesseract-
> OCR / tesseract '
> Print (pytesseract.image_to_string (Image.open ('CAMARA.tif'), lang = "spa"))

问题是只提取第一页。如何提取所有这些?

我能够通过调用方法来解决同样的问题convert()

如下所示
image = Image.open(imagePath).convert("RGBA")
text = pytesseract.image_to_string(image)
print(text)

我猜你只提到了一个图像"camara.tif",首先你必须将所有pdf页面转换为图像,你可以看到这个链接这样做。

接下来使用pytesseract逐个循环图像以从图像中提取文本。

我只是偶然发现了同样的问题......你可以做的是直接调用Tesseract。

# test.py
import subprocess
in_filename = 'file_0.tiff'
out_filename = 'out'
lang = 'spa'
subprocess.call(['tesseract', in_filename, '-l', lang, out_filename ])

将处理所有页面

$ 蟒蛇 test.py Tesseract 开源 OCR 引擎 v4.0.0-beta.1 与 Leptonica 第 1 页 第 2 页 第 3 页

最新更新