在linux下安装tesseract-ocr

来源:互联网 发布:双十一淘宝成交额 编辑:程序博客网 时间:2024/04/30 16:13

注意:下面的下载网址和版本有更新的以最新的为准



1. 在ubuntu下可以自动安装  

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install tesseract-ocr  

2.编译安装

    a.编译环境: gcc gcc-c++ make(这个环境一般机器都具备,可以忽略)   

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. yum install gcc gcc-c++ make  


    b.安装tesseract-ocr编译必须的包

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. yum/apt-get install autoconf automake libtool  


    c.增加图像解析需要的包,可以按照指定的格式选择包

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. yum install libjpeg-devel libpng-devel libtiff-devel zlib-devel  

    ubuntu

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. sudo apt-get install libpng12-dev  
  2. sudo apt-get install libjpeg62-dev  
  3. sudo apt-get install libtiff4-dev  

    d.下载 leptonica 包: http://www.leptonica.org/source/leptonica-1.71.tar.gz
[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. wget http://www.leptonica.org/source/leptonica-1.71.tar.gz  
  2. tar -zxvf ...  
  3. ./configure  
  4. make  
  5. 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.)

如果版本不一致,会出现问题如下:

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. Tesseract Open Source OCR Engine v3.02.02 with Leptonica  
  2. Error in findTiffCompression: function not present  
  3. Error in pixReadStreamTiff: function not present  
  4. Error in pixReadStream: tiff: no pix returned  
  5. Error in pixRead: pix not read  
  6. Unsupported image type.  


    e.下载 tesseract-3.02 安装包: http://tesseract-ocr.googlecode.com/files/tesseract-3.02.02.tar.gz

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. wget http://tesseract-ocr.googlecode.com/files/tesseract-ocr-3.02.02.tar.gz  
  2. ./autogen.sh  
  3. ./configure  
  4. make  
  5. make install  
  6. 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 下。



     测试

[html] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. tesseract phototest.tif phototest -l eng  
这时应该在当前目录生成一个 phototest.txt 文本文件,内容就是 phototest.tif 显示的文字.

0 0