python 图像识别pytesseract快速设置
生活随笔
收集整理的這篇文章主要介紹了
python 图像识别pytesseract快速设置
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一、安裝Tesseract
以window安裝為例,參考:https://segmentfault.com/a/1190000014086067
note:
使用虛擬環(huán)境需要:
在 python 環(huán)境(或虛擬環(huán)境) \Lib\site-packages\pytesseract 目錄下找到 pytesseract.py ,
打開 pytesseract.py , 在 32行 ,找到 變量 tesseract_cmd,修改 tesseract_cmd 值:
tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'參考:https://www.pythonheidong.com/blog/article/753756/41839878d41e6db7e422/
二、python code
a.安裝依賴
pip install pytesseract pip install pillowb.sample code
simple.pnd為測試圖片,注意是否當(dāng)前的路徑。
import pytesseract from PIL import Imageimage = Image.open("simple.png") code = pytesseract.image_to_string(image) print(code)參考:https://segmentfault.com/a/1190000014091417
總結(jié)
以上是生活随笔為你收集整理的python 图像识别pytesseract快速设置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python FastApi:post文
- 下一篇: pytesseract:opencv预处