1 from PIL import Image 2 from pytesser import * 3 image = Image.open('7039.jpg') 4 print image_file_to_string('7039.jpg') 5 print image_to_string(image)
備註:若是出現報錯ImportError: The _imaging C module is not installed,可能出現的緣由下載錯了版本,更改下安裝64位的版本python
pytesser是谷歌OCR開源項目的一個模塊,在python中導入這個模塊便可將圖片中的文字轉換成文本,可是在pytesser模塊中調用了tesseract,因此須要先安裝tesseractwindows
tesseract下載路徑:https://bitbucket.org/3togo/python-tesseract/downloads/,選擇合適的版本進行下載安裝ide
圖片識別源碼google
1 from PIL import Image 2 from pytesser import * 3 image = Image.open('7039.jpg') 4 print image_file_to_string('7039.jpg') 5 print image_to_string(image)
文件示例 7039.jpgspa
可能遇到的問題及解決方案:code