鏈接:https://pan.baidu.com/s/1l2yiba7ZTPUTf41ZnJ4PYw
提取碼:t3bq
win10安裝tesserocr
首先需要下載tesseract,它為tesserocr提供底層支持。具體下載官方路徑:https://github.com/UB-Mannheim/tesseract/wiki,選擇對(duì)應(yīng)的系統(tǒng)版本,可以選擇一個(gè)相對(duì)不帶dev的穩(wěn)定版本下載,如:tesseract-ocr-setup-3.05.02-20180621.exe。然后一路安裝,唯一記得勾選Additional language data(download),勾選可能會(huì)用到的語(yǔ)言tessdata,如簡(jiǎn)體、繁體中文,數(shù)學(xué)模塊等,不需要全選,下載tessdata的時(shí)間會(huì)比較長(zhǎng)。
下載時(shí)間會(huì)比較長(zhǎng),耐心等待即可,有條件可以翻墻下載速度會(huì)快很多
安裝python對(duì)應(yīng)的tesserocr庫(kù)
使用原始的whl文件方式安裝。tesserocr 的whl官方文件下載路徑:https://github.com/simonflueckiger/tesserocr-windows_build/releases,下載本地環(huán)境對(duì)應(yīng)的whl文件,如我的是window64位系統(tǒng),python版本是3.5。下載完后,使用cd跳轉(zhuǎn)到whl文件所在目錄,然后 執(zhí)行 ”pip install tesserocr-2.2.2-cp35-cp35m-win_amd64.whl“,即可輕松完成安裝。
tesserocr 報(bào)錯(cuò) UnicodeDecodeError 系統(tǒng)問題 用下面的模塊替代
pytesseract :pip install pytesseract
pip install pytesseract
首次運(yùn)行總是不順利,相信我遇到的坑大多數(shù)人都會(huì)遇到,大抵錯(cuò)誤類似:
1
2
3
4
|
Traceback (most recent call last): File "G:\pythonSources\my12306/obtain_message\test.py" , line 4 , in <module> print (tesserocr.image_to_text(image)) File "tesserocr.pyx" , line 2400 , in tesserocr._tesserocr.image_to_text RuntimeError: Failed to init API, possibly an invalid tessdata path: “本地某個(gè)路徑” |
有個(gè)比較簡(jiǎn)單粗暴的解決方法是把安裝好的Tesseract-OCR下的tessdata文件夾整個(gè)拷貝到提示的那個(gè)路徑中,親測(cè)有效。
測(cè)試代碼
1
2
3
4
|
import tesserocr from PIL import Image image=Image.open('image.jpg') print(tesserocr.image_to_text(image)) |
總結(jié)
以上所述是小編給大家介紹的win10安裝tesserocr配置 Python使用tesserocr識(shí)別字母數(shù)字驗(yàn)證碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)服務(wù)器之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
原文鏈接:https://blog.csdn.net/qq_38154948/article/details/103988080