Python pytesseract驗(yàn)證碼識別庫用法解析
環(huán)境 centos7 python3
pytesseract只是tesseract-ocr的一種實(shí)現(xiàn)接口。所以要先安裝tesseract-ocr(大名鼎鼎的開源的OCR識別引擎)。
依賴安裝
yum install-y automake autoconf libtool gcc gcc-c++yum install-y libpng-devel libjpeg-devel libtiff-devel giflib-devel
安裝依賴的leptonica庫
wget http://www.leptonica.com/source/leptonica-1.72.tar.gz tar -xzvf leptonica-1.72.tar.gz cd leptonica-1.72./configuremake && make install
安裝tesseract-ocr
wget https://github.com/tesseract-ocr/tesseract/archive/3.04.00.tar.gzmv 3.04.00 Tesseract3.04.00.tar.gztar -xvf Tesseract3.04.00.tar.gz cd tesseract-3.04.00/./configuremake && make install
安裝語言包:
wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata #英文默認(rèn)包wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_sim.traineddata #中文繁體wget https://github.com/tesseract-ocr/tessdata/raw/master/chi_tra.traineddata #中文簡體cp/mv *.traineddata /usr/local/share/tessdata/ #移動下載的包到/usr/local/share/tessdata/ 這個(gè)路徑下,也可以手動移動
安裝pytesseract:
pip install Pillowpip install pytesseract
至此安裝完成,附上使用方法:
import pytesseract from PIL import Imagimage = Image.open('port_img.jpg')text = pytesseract.image_to_string(image)print(text)
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. php模擬實(shí)現(xiàn)斗地主發(fā)牌2. Python random庫使用方法及異常處理方案3. 理解PHP5中static和const關(guān)鍵字4. spring acegi security 1.0.0 發(fā)布5. Vue封裝一個(gè)TodoList的案例與瀏覽器本地緩存的應(yīng)用實(shí)現(xiàn)6. Vuex localStorage的具體使用7. jQuery 實(shí)現(xiàn)DOM元素拖拽交換位置的實(shí)例代碼8. .Net Core使用Coravel實(shí)現(xiàn)任務(wù)調(diào)度的完整步驟9. vue 使用localstorage實(shí)現(xiàn)面包屑的操作10. MyBatis中的JdbcType映射使用詳解

網(wǎng)公網(wǎng)安備