- 安装python和pip不作介绍,保证打开cmd输入pip和python有反应。需设置环境变量。python3.6安装包
- 在cmd中执行以下命令(怎么启动cmd)
1 | pip install PIL |
目标图片
识别代码(python3)
如果出现无法导入需要自己解决依赖问题1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21from PIL import Image
from pytesseract import *
im = Image.open('index.png')
im = im.convert('L')
def initTable(threshold=140):
table = []
for i in range(256):
if i < threshold:
table.append(0)
else:
table.append(1)
return table
binaryImage = im.point(initTable(), '1')
#binaryImage.show()
print(image_to_string(binaryImage, config='-psm 7'))结果截图