Use pytesseract OCR to recognize text from an image

后端 未结 6 755
北恋
北恋 2020-11-30 20:02

I need to use Pytesseract to extract text from this picture:

and the code:

from PIL import Image, ImageEnhance, ImageFilter
import pytesseract
         


        
6条回答
  •  一生所求
    2020-11-30 20:27

    Here is my solution:

    import pytesseract
    from PIL import Image, ImageEnhance, ImageFilter
    
    im = Image.open("temp.jpg") # the second one 
    im = im.filter(ImageFilter.MedianFilter())
    enhancer = ImageEnhance.Contrast(im)
    im = enhancer.enhance(2)
    im = im.convert('1')
    im.save('temp2.jpg')
    text = pytesseract.image_to_string(Image.open('temp2.jpg'))
    print(text)
    

提交回复
热议问题