我正在使用pytesser对一张小图像进行OCR,并从中获取一个字符串:
image= Image.open(ImagePath)
text = image_to_string(image)
print text
然而,pytesser有时候会识别并返回非ascii字符,当我想要打印刚刚识别出来的内容时,就会出现问题,在我使用的python 2.7版本中,程序会崩溃。
有没有办法让pytesser不返回任何非ascii字符呢?也许在tesseract OCR中有一些可以更改的东西吗?
还是有没有一种方法来测试一个字符串是否包含非ascii字符(而不会导致程序崩溃),然后仅仅不打印这一行内容?
有人建议使用python 3.4,但根据我的研究,似乎pytesser不适用于它:Python 3.4中的Pytesser:name 'image_to_string'未定义?
from unidecode import unidecode
- Sreeragh A R