在python中使用pytesseract模塊實現一個圖像識別,具體方法如下:
import pytesseract #導入pytesseract模塊
from PIL import Image
class GetImageDate(object):
def m(self):
image = Image.open(u"a.png")
text = pytesseract.image_to_string(image)
return text
def SaveResultToDocument(self):
text = self.m()
f = open(u"Verification.txt","w")
print text
f.write(str(text))
f.close()
g = GetImageDate()
g.SaveResultToDocument()