1.
ubuntu 下可以直接进行安装
命令:
sudo apt-get install tesseract-ocr
2.其他linux版本
编译安装
a.编译环境: gcc gcc-c++ make(这个环境一般机器都具备,可以忽略)
yum/apt-get install gcc gcc-c++ make
b.安装tesseract-ocr编译必须的包
yum/apt-get install autoconf automake libtool
c.增加图像解析需要的包,可以按照指定的格式选择包
yum/apt-get install libjpeg-devel libpng-devel libtiff-devel zlib-devel
ubuntu
sudo apt-get install libpng12-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libtiff4-dev
d.下载 leptonica 包: http://www.leptonica.org/source/leptonica-1.71.tar.gz
- wget http://www.leptonica.org/source/leptonica-1.71.tar.gz
- tar -zxvf ...
- ./configure
- make
- make install
如果无法在命令行里下载可以进入网页进行下载,然后再在命令行里解压安装
需要注意,leptonica的版本问题
3.01 requires at least v1.67 of Leptonica.
3.02 requires at least v1.69 of Leptonica. (Both available in Ubuntu 12.04 Precise Pangolin.)
3.03 requires at least v1.70 of Leptonica. (Both available in Ubuntu 14.04 Trusty Tahr.)
如果版本不一致,会出现问题如下:
- Tesseract Open Source OCR Engine v3.02.02 with Leptonica
- Error in findTiffCompression: function not present
- Error in pixReadStreamTiff: function not present
- Error in pixReadStream: tiff: no pix returned
- Error in pixRead: pix not read
- Unsupported image type.
e.下载 tesseract-3.02 安装包: http://tesseract-ocr.googlecode.com/files/tesseract-3.02.02.tar.gz
- wget http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz
- ./autogen.sh
- ./configure
- make
- make install
- ldconfig
f.下载 tesseract-3.02 英文语言包: http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.eng.tar.gz,解压后将 tesseract-ocr/tessdata 下的所有文件全部拷贝到 /usr/local/share/tessdata 下。
测试时可以用.jpg图片格式进行测试。