TesseractOCR,可以直接將圖片中的文字進(jìn)行識別,其最新版本3.0已經(jīng)支持中文OCR,并提供了一個(gè)命令行工具,轉(zhuǎn)換成文本信息。tesseract-ocr官方下載據(jù)說曾經(jīng)的圖像識別能力排名第三。tesseract-ocr中文版可以識別多種格式的圖像文件并將其轉(zhuǎn)換成文本,目前已支持60多種語言(包括中文)。 Tesseract最初由HP公司開發(fā),后來由Google維護(hù),目前發(fā)布在Googel Project上。
windows下的安裝非常簡單,直接安裝可執(zhí)行程序即可。當(dāng)你選擇安裝各類語言之時(shí),則需要一個(gè)稍微耗時(shí)的等待操作,比如下圖中所示的信息:
tesseract-ocr中文版安裝使用教程:
下載完后進(jìn)行安裝,默認(rèn)情況下安裝程序會(huì)給你配置系統(tǒng)環(huán)境變量,以指向安裝目錄(之后可以通過DOS界面在任意目錄運(yùn)行tesseract)。安裝完成后目錄如下:
附錄:
tessdata 目錄存放的是語言字庫文件,和在命令行界面中可能用到的參數(shù)所對應(yīng)的文件. 這個(gè)安裝程序默認(rèn)包含了英文字庫。
使用Tessract-OCR引擎識別驗(yàn)證碼
打開DOS界面,輸入tesseract:
如果出現(xiàn)如上輸出,表示安裝正常。
我準(zhǔn)備了一張驗(yàn)證碼code.jpg放在D盤根目錄下,上圖:
結(jié)果為:
附錄:
Usage:tesseract imagename 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 image as a single text line.
8 = Treat the image as a single word.
9 = Treat the image as a single word in a circle.
10 = Treat the image as a single character.
-l lang and/or -psm pagesegmode must occur before anyconfigfile.
tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...]
tesseract 圖片名 輸出文件名 -l 字庫文件 -psm pagesegmode 配置文件
例如:
tesseract code.jpg result -l chi_sim -psm 7 nobatch
-l chi_sim 表示用簡體中文字庫(需要下載中文字庫文件,解壓后,存放到tessdata目錄下去,字庫文件擴(kuò)展名為 .raineddata 簡體中文字庫文件名為: chi_sim.traineddata)
-psm 7 表示告訴tesseract code.jpg圖片是一行文本 這個(gè)參數(shù)可以減少識別錯(cuò)誤率. 默認(rèn)為 3
configfile 參數(shù)值為tessdata\configs 和 tessdata\tessconfigs 目錄下的文件名