Python pytesseract驗(yàn)證碼識(shí)別庫(kù)用法解析
環(huán)境 centos7 python3
pytesseract只是tesseract-ocr的一種實(shí)現(xiàn)接口。所以要先安裝tesseract-ocr(大名鼎鼎的開(kāi)源的OCR識(shí)別引擎)。
依賴(lài)安裝
yum install-y automake autoconf libtool gcc gcc-c++yum install-y libpng-devel libjpeg-devel libtiff-devel giflib-devel
安裝依賴(lài)的leptonica庫(kù)
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
安裝語(yǔ)言包:
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 #中文簡(jiǎn)體cp/mv *.traineddata /usr/local/share/tessdata/ #移動(dòng)下載的包到/usr/local/share/tessdata/ 這個(gè)路徑下,也可以手動(dòng)移動(dòng)
安裝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)
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 讀大數(shù)據(jù)量的XML文件的讀取問(wèn)題2. 概述IE和SQL2k開(kāi)發(fā)一個(gè)XML聊天程序3. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享4. jsp文件下載功能實(shí)現(xiàn)代碼5. JSP+Servlet實(shí)現(xiàn)文件上傳到服務(wù)器功能6. ASP實(shí)現(xiàn)加法驗(yàn)證碼7. 低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案8. JSP之表單提交get和post的區(qū)別詳解及實(shí)例9. asp知識(shí)整理筆記4(問(wèn)答模式)10. javascript xml xsl取值及數(shù)據(jù)修改第1/2頁(yè)
