【基本用法】
創(chuàng)新互聯服務項目包括洛江網站建設、洛江網站制作、洛江網頁制作以及洛江網絡營銷策劃等。多年來,我們專注于互聯網行業(yè),利用自身積累的技術優(yōu)勢、行業(yè)經驗、深度合作伙伴關系等,向廣大中小型企業(yè)、政府機構等提供互聯網行業(yè)的解決方案,洛江網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到洛江省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!1、tesseract 基本語法:
Usage:tesseract.exe p_w_picpathname outputbase [-l lang] [-psm pagesegmode] [configfile...] pagesegmode values are: 0 = Orientation and script detection (OSD) only. 1 = Automatic page segmentation with OSD. 2 = Automatic page segmentation, but no OSD, or OCR 3 = Fully automatic page segmentation, but no OSD. (Default) 4 = Assume a single column of text of variable sizes. 5 = Assume a single uniform block of vertically aligned text. 6 = Assume a single uniform block of text. 7 = Treat the p_w_picpath as a single text line. 8 = Treat the p_w_picpath as a single word. 9 = Treat the p_w_picpath as a single word in a circle. 10 = Treat the p_w_picpath as a single character. -l lang and/or -psm pagesegmode must occur before anyconfigfile. Single options: -v --version: version info --list-langs: list available languages for tesseract engine tesseract p_w_picpathname outputbase [-l lang] [-psm pagesegmode] [configfile...] tesseract 圖片名 輸出文件名 -l 字庫文件 -psm pagesegmode 配置文件
2、示例:
(1)、
tesseract code.jpg code -l chi_sim -psm 7 digits code 生成code.txt的結果文件 -l chi_sim 表示用簡體中文字庫 -psm 7 表示告訴tesseract code.jpg圖片是一行文本,默認為 3 configfile 參數值為tessdata\configs 和 tessdata\tessconfigs 目錄下的文件名 digits 內容為 tessedit_char_whitelist 0123456789-. 表示數字
(2)、白名單
tesseract code.jpg code -l eng -psm 7 -c tessedit_char_whitelist="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
(2)、黑名單
tesseract code.jpg code -l eng -psm 7 -c tessedit_char_blacklist="abcdefghijklmnopqrstuvwxy"
【訓練】(以訓練arial字體為例)
1、準備一張字體圖片如下。

2、用 jTessBoxEditor 將圖片轉為tif文件,將tif文件命名為 eng.arial.exp0.tif。注意這里其實可以選多張圖片。
Tools -> Merge TIFF...
3、生成坐標文件(.box)。
tesseract.exe eng.arial.exp0.tif eng.arial.exp0 batch.nochop makebox
【語法】:tesseract [lang].[fontname].exp[num].tif [lang].[fontname].exp[num] batch.nochop makebox
lang為語言名稱,fontname為字體名稱,num為序號;在tesseract中,一定要注意格式。
4、在當前目錄創(chuàng)建 font_properties 文件,內容如下。
eng.arial.exp0.box 1 1 1 0 0
【語法】:<fontname> <italic> <bold> <fixed> <serif> <fraktur>
fontname為字體名稱,italic為斜體,bold為黑體字,fixed為默認字體,serif為襯線字體,fraktur德文黑字體,1和0代表有和無,精細區(qū)分時可使用。
5、字符校正。
打開jTessBoxEditor,BOX Editor -> Open,打開 eng.arial.exp0.tif,注意多頁時頁面切換。
6、執(zhí)行批處理文件(arial.bat),生成.traineddata文件。
echo Run Tesseract for Training.. tesseract eng.arial.exp0.tif eng.arial.exp0 nobatch box.train echo Compute the Character Set.. unicharset_extractor eng.arial.exp0.box mftraining -F font_properties -U unicharset -O arial.unicharset eng.arial.exp0.tr echo Clustering.. cntraining eng.arial.exp0.tr echo Rename Files.. rename normproto arial.normproto rename inttemp arial.inttemp rename pffmtable arial.pffmtable rename shapetable arial.shapetable echo Create Tessdata.. combine_tessdata arial. echo. & pause
7、將生成文件中的arial.traineddata 文件拷貝到相應tessdata目錄就可以使用啦!
tesseract code.jpg code -l arial
【參考文獻】
1、啥都不懂也能識別驗證碼
2、Tesseract-OCR的簡單使用與訓練
3、Adding New Fonts to Tesseract 3 OCR Engine
4、Python做簡單的驗證碼識別(ocr)
*** walker ***
另外有需要云服務器可以了解下創(chuàng)新互聯scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
分享標題:tesseract-ocrtips-創(chuàng)新互聯
新聞來源:http://chinadenli.net/article2/ceeeic.html
成都網站建設公司_創(chuàng)新互聯,為您提供網站制作、App設計、定制開發(fā)、微信公眾號、網站內鏈、Google
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯