2015-10-03 163 views
3

我在Pytesseract的屏幕截圖上運行大量OCR。這在大多數情況下都能正常工作,但是一小部分會導致此錯誤:Pytesseract:UnicodeDecodeError:'charmap'編解碼器無法解碼字節

pytesseract.image_to_string(image,None, False, "-psm 6") 
Pytesseract: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 2: character maps to <undefined> 

我正在使用Python 3.4。任何建議如何我可以防止這種錯誤發生(除了只是一個嘗試/除外)將是非常有益的。

+0

你見過答案在這裏找到:http://stackoverflow.com/a/34293514/2029846 – wittrup

回答

2

使用Unidecode

from unidecode import unidecode 
import pytesseract 

strs = pytesseract.image_to_string(Image.open('binarized_image.png')) 
strs = unidecode(strs) 
print (strs) 
相關問題