我有使用pytesseract的代码和完美的工作,只有当我尝试识别的图像是0到9时才工作.如果图像只有一个数字不给任何结果.
这是我正在使用的图片示例 https://drive.google.com/folderview?id=0B68PDhV5SW8BdFdWYVRwODBVZk0&usp=sharing
这就是我正在使用的代码
import pytesseract
varnum= pytesseract.image_to_string(Image.open('images/table/img.jpg'))
varnum = float(varnum)
print varnum
Run Code Online (Sandbox Code Playgroud)
谢谢!!!!
使用此代码,我可以读取所有数字
import pytesseract
start_time = time.clock()
y = pytesseract.image_to_string(Image.open('images/table/1.jpg'),config='-psm 10000')
x = pytesseract.image_to_string(Image.open('images/table/1.jpg'),config='-psm 10000')
print y
print x
y = pytesseract.image_to_string(Image.open('images/table/68.5.jpg'),config='-psm 10000')
x = pytesseract.image_to_string(Image.open('images/table/68.5.jpg'),config='-psm 10000')
print y
print x
print time.clock() - start_time, "seconds"
Run Code Online (Sandbox Code Playgroud)
结果
>>>
1
1
68.5
68.5
0.485644155358 seconds
>>>
Run Code Online (Sandbox Code Playgroud)