Tag Archives: 图像识别

Python 操作图片识别,对比,验证码之PIL,pytesseract

安装python包 pip3 install pillow pip3 install pytesseract pytesseract的使用需要安装对应的Tesseract-OCR程序,无论是windows系统还是Lunix系统,都可以到GitHub下载相关版本。 链接:https://github.com/tesseract-ocr/tesseract/ 安装完成后,把你安装tesseract的路径添加到你电脑的环境变量path中, 或者修改pytesseract.py文件,指定tesseract.exe安装路径 # CHANGE THIS IF TESSERACT IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY tesseract_cmd = ‘C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe’ 或者在实际运行中指定路径 pytesseract.pytesseract.tesseract_cmd = ‘D:\\Program Files\\Tesseract-OCR\\tesseract.exe’ 读取图片里面文字: from PIL import Image import pytesseract img = Image.open(’test1.png’) text = pytesseract.image_to_string(img, lang=’eng’) print(text) image_to_string函式有一个关键字引数 lang,默认是英文,可以改变成你想要的语言字串 pytesseract.image_to_string(img, lang=’eng’,config=’–psm 11… Read More »