Requirement
sudo apt-get install libpng12-dev sudo apt-get install libjpeg62-dev sudo apt-get install libtiff4-dev sudo apt-get install gcc sudo apt-get install g++ sudo apt-get install automake
Install leptonica
wget http://www.leptonica.org/source/leptonlib-1.67.tar.gz sudo tar -zxvf leptonlib-1.67.tar.gz cd leptonlib-1.67 sudo ./configure sudo make sudo make install
Download & Install
Tesseract 3.00 source
http://code.google.com/p/tesseract-ocr/downloads/list
sudo wget http://tesseract-ocr.googlecode.com/files/tesseract-3.00.tar.gz sudo tar xvf tesseract-3.00.tar.gz cd tesseract-3.00 sudo ./runautoconf sudo ./configure sudo make sudo make install cd /usr/local/share/tessdata sudo wget http://tesseract-ocr.googlecode.com/files/eng.traineddata.gz sudo gunzip eng.traineddata.gz
Test
必須先安裝 imagemagick 才能使用 convert
sudo apt-get install imagemagick
此範例中, 圖檔都必須透過 convert 轉成黑白的 tif
cd ~ wget -O test.png http://people.chu.edu.tw/~c9003076/test.png convert test.png -type Grayscale -depth 8 test.tif # 只能支援到 depth 8 tesseract test.tif result cat result.txt
Tesseract 3.0目前對於圖檔格式仍以 tif 為主舊版 (2.04) 支援度更差, 必須轉換成 8bit 的 tif 檔才能讀取即 convert test.png -type Grayscale test.tif 後必須再
convert test.tif -depth "8" test.tif
除 eng.traineddata.gz3.0 也支援了其他語言的 OCR可在 http://code.google.com/p/tesseract-ocr/downloads/list
取得其他 trained data執行中只要加入參數 -l [lang code] 即可如
tesseract test.tif result -l chi_tra即代表讀取中文 trained data 進行 OCR
如何使用 tesseract 內建的工具產生自己的 training data
下回分解 :p
沒有留言:
張貼留言