2017-07-11 60 views
0

獲取文本我需要使用pytesseract從這張照片中提取文本:enter image description here從圖像

但是,我用pytesseract。它不會work.Here是我的代碼:

try: 
    import Image 
except ImportError: 
    from PIL import Image 
import pytesseract 

print(pytesseract.image_to_string(Image.open('1.png'))) 
+0

你能提供你得到的錯誤嗎? – Chobeat

+0

確保您已下載tesseract並設置您的系統以正確運行。 pytesseract取決於tesseract – jlaur

+0

是的,我已經下載tesseract和它的正常運行。其實它沒有打印,併爲所述錯誤感到抱歉。 – GMB

回答

0
您在使用這一點,我們可以從中提取任何擴展文本安裝 textract

# some python file 
import textract 
text = textract.process("path/to/file.extension") 

您可以提供file作爲圖像或pdf或任何文檔。 爲您的代碼

text = textract.process("1.png")