简体   繁体   中英

Pytesseract output is completely different from the text in the image

The following code runs on my friend's windows laptop perfectly but on mine, it spits out complete garbage. I think it might have something to do with the libraries but I can't say for sure? Can you guys let me know if it runs for you or if you have ever had this happen before?

import pytesseract
from PIL import Image, ImageEnhance, ImageFilter
from textblob import TextBlob

originalImage = Image.open("pictures\hp.png")
workingImage = originalImage.copy()
workingImage = originalImage.filter(ImageFilter.MedianFilter())

enhanceSharpness = ImageEnhance.Sharpness(workingImage)
enhanceColor = ImageEnhance.Color(workingImage)

workingImage = enhanceSharpness.enhance(2)
workingImage = enhanceColor.enhance(0)
workingImage = workingImage.convert('1')

text = pytesseract.image_to_string(workingImage)
correctedText = TextBlob(text).correct()

print(correctedText)

This is the picture we are feeding it: 在此处输入图片说明

Rather than printing the text in the photo as it does on my friend's computer, mine prints the following:

of was an am: came: mm: mmm mm bu noma of arm 523w at"
mmmhmg peaches? w 3 cm {mamma a map m: K wm} Or Mummy
didn‘c realm when Am had cm then he mmm Am: Ma mad m

Am!» adam Them was 3 W317); Ll them on arm mmm a‘met
Turn mm "mm wasn't a mm: m 313% Ham sum Am have. term mmm
M‘) It must had: {mm 3 mm fiftht‘ High: Or Him‘cy [asked and
hated :31 me cm of Taxed back Of I Mummy time mound! m:

come and up in: may M maxim} tin: ca: m Am mm‘m h Am raw
made m: mm mm mid and Run“ w Of iwkmg at me 5 Is
cmricbfl mad may or $$ka Or [)unity gave hrmsuifa hut: wake and
put 11% cm my m“ Am Am} Is he rim mere own M {high W
msihmg except & Large may of'dry‘b M. M h my m E“ that thy

I downloaded tesseract-ocr version 4.0 and it works perfectly now. Thanks for all your help guys!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM