1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python图像识别代码_python图像识别--验证码

python图像识别代码_python图像识别--验证码

时间:2020-07-18 15:53:58

相关推荐

python图像识别代码_python图像识别--验证码

1、pip3 install pyocr

2、pip3 install pillow or easy_install Pillow

4、要求python默认安装在C盘

5、找到 pytesseract.py 更改 tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'

代码:

# !/usr/bin/python3.4

# -*- coding: utf-8 -*-

import pytesseract

from PIL import Image

image = Image.open('../jpg/code.png')

code = pytesseract.image_to_string(image)

print(code)

如果出现错误:

'str' does not support the buffer interface

将 `pytesseract.py` 中的下面语句更换:

1 lines =error_string.splitlines()2 #error_lines = tuple(line for line in lines if line.find('Error') >= 0)

3 error_lines = tuple(line.decode('utf-8') for line in lines if line.find(b'Error') >=0)4 if len(error_lines) >0:5 return '\n'.join(error_lines)6 else:7 return error_string.strip()

如果要识别更多的文字,需要在安装tesseract-ocr的时候选择全部语言,也就1.3G

识别精度不是很高,要不就是现在的验证码太变态,人为也看不出来是什么

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。