当Python遇到PIL|pytesser图像处理出错


微笑

import pytesser
From PIL import Image
im = Image.open('1.png')
im.show()#查看图片
print pytesser.image_to_string(im)#识别图像的字符串




这样会报错如下:

C:\Python27\python.exe C:/Users/ED/PycharmProjects/untitled/1t.py
Traceback (most recent call last):
File "C:/Users/ED/PycharmProjects/untitled/1t.py", line 14, in <module>
print pytesser.image_to_string(im)
File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 31, in

image_to_string
call_tesseract(scratch_image_name, scratch_text_name_root)
File "C:\Python27\lib\site-packages\pytesser\pytesser.py", line 21, in call_tesseract
proc = subprocess.Popen(args)
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2]

解决方法:
import os
os.chdir('c:/Python27/Lib/site-packages/pytesser')#修改工作路径即可
简单的数字和英文的图像识别就完成了



注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2018 ITdaan.com 粤ICP备14056181号