以下代码可以在我朋友的Windows笔记本电脑上完美运行,但在我的笔记本电脑上,它会吐出全部垃圾。我认为这可能与库有关,但我不能确定地说吗?你们可以让我知道它是否为您运行,或者您以前是否曾经发生过?
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)
我不会像在朋友的计算机上那样打印照片中的文本,而是打印以下内容:
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
答案 0 :(得分:2)
我下载了tesseract-ocr 4.0版,现在可以正常使用了。感谢您的帮助!