使用python pytesseract从图像中提取文本

时间:2019-06-11 10:42:28

标签: python image-processing ocr image-recognition python-tesseract

这是我第一次使用OCR。我有一张图片,想从图片中提取数据。我的图片看起来像这样:

enter image description here

我有500张这样的图像,将不得不记录参数和各自的值。我正在考虑通过代码而不是手动进行。

我尝试使用python py-tesseract和PIL库。如果图片中包含一些简单的文字,它们的效果就会很好。这就是我尝试过的


from PIL import Image, ImageEnhance, ImageFilter

from pytesseract import image_to_string

from pytesseract import image_to_boxes

im = Image.open("AHU.png")
im = im.filter(ImageFilter.MedianFilter())
enhancer = ImageEnhance.Contrast(im)
im = enhancer.enhance(2)
im = im.convert('1')
im.save('temp2.jpg')
text = image_to_string(Image.open('temp2.jpg'))
print(text)

在有多个参数的情况下该怎么办?我所有的图像在值位置方面都是相似的。

0 个答案:

没有答案