使用python

时间:2019-08-22 09:28:15

标签: python-3.x ocr python-tesseract pdfminer pdf-extraction

我正在通过tesseract ocr从扫描的pdf中提取数据,我能够提取数据,但准确性不高。在许多地方,它显示了错误的数据,因此我可以通过python以100%的精度获取数据。

首先我将pdf转换为jpg格式,然后使用tesseract模块从图像中提取数据。

from PIL import Image
import pytesseract

text=(pytesseract.image_to_string(Image.open(r"C:\Users\sumesh\Desktop\ip\ip\pdf11.jpg")))
text=repr(text)
text=text.replace(r"\n","")
print(text)

我希望从pdf中获得适当的数据,但是我得到了不同的数据,例如z显示2,5是s,1是I,等等。

2 个答案:

答案 0 :(得分:0)

希望下面的一些小改动对您有所帮助。

from PIL import Image
import pytesseract

text=str(pytesseract.image_to_string(Image.open(r"C:\Users\sumesh\Desktop\ip\ip\pdf11.jpg"),lang='eng'))

text=text.replace("\n","")

print(text)

答案 1 :(得分:0)

请在文件路径后使用“ DPI = 500”,这可能会有所帮助。 有关更多信息,您可以按照我在这里How to convert .png images to searchable PDF/word using Python

发布的答案
相关问题