通过编译代码形式在服务器上安装Tesseract-OCR最新版了
安装基本的CentOS依赖项
yum install autoconf automake libtool pkgconfig.x86_64 libpng12-devel.x86_64 libjpeg-devel libtiff-devel.x86_64 zlib-devel.x86_64
- 如果新机器就随手安装上工具包
yum install gtk2-devel yasm glibc.i686 libstdc++.so.6 libgtk-x11-2.0.so libatk-1.0.so.0 libcairo.so.2 libcups.so.2 libgdk-x11-2.0.so.0 libgdk_pixbuf-2.0.so.0 libgtk-x11-2.0.so.0 libpango-1.0.so.0 libpangocairo-1.0.so.0 libICE.so.6 libSM.so.6 libmng.so.1 libpng12.so.0 libGLU.so.1 -y
- 安装开发工具
yum groupinstall "Development Tools"
安装leptonica1.82.0(latest)
wget http://www.leptonica.org/source/leptonica-1.82.0.tar.gz
tar -xzvf leptonica-1.82.0.tar.gz
cd leptonica-1.82.0
./configure --prefix=/usr/local/
make && make install
配置环境PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
vim \etc\bashrc
加入
export PKG_CONFIG_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/include/
export CPLUS_INCLUDE_PATH
C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/leptonica/include/leptonica
export C_INCLUDE_PATH
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LIBRARY_PATH
TESSDATA_PREFIX=/root/tesseract/
export TESSDATA_PREFIX 最后刷新 source /etc/bashrc
编译tesseract-5.0
yum install git
git clone https://github.com/tesseract-ocr/tesseract.git
回到tesseract目录,开始安装
cd tesseract
./autogen.sh
./configure --with-extra-includes=/usr/local/include --with-extra-libraries=/usr/local/include
注:这时有可能会报 configure: error: Leptonica 1.82 or higher is required. Try to install libleptonica-dev package.
明明我们已经安装了的。为什么还会报呢?
那就要加入环境变量
vim /etc/profile
在最后插入
export LD_LIBRARY_PATH=$LD_LIBRARY_PAYT:/usr/local/lib
export LIBLEPT_HEADERSDIR=/usr/local/include
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
最后刷新下文件
source /etc/profile
然后我们再执行
./autogen.sh ./configure --with-extra-includes=/usr/local/include --with-extra-libraries=/usr/local/include
这时就没有 leptonica问题啦,随后make下
make && sudo make install
最后我们用代码测试一切都正常,但到项目中却莫明奇妙地失败,断点服务直接崩掉,cache不住,找不到报错
各种百度google最后确认下来可能少了tess4j要的linux依赖库
执行下
cp /usr/local/lib/*.so.* /usr/lib64/
如果报
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.
相关。
那就是没有少了png和jpge依赖库
yum install libjpeg-devel yum install libpng-devel
如果报
configure: error: Your compiler does not have the necessary C++17 support! Cannot proceed.
需要升级GCC版本,执行命令
yum install -y centos-release-scl
yum install devtoolset-8-gcc*
完成后切换当前会话中的gcc版本为8
scl enable devtoolset-8 bash
或者切换当前会话中的gcc版本为8
mv /usr/bin/gcc /usr/bin/gcc-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
mv /usr/bin/g++ /usr/bin/g++-4.8.5
ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++
执行命令查看版本
gcc -v
进入leptonica的安装文件夹重新编译
./configure make make install
参考:
https://blog.csdn.net/weixin_41228101/article/details/109624733
https://www.cnblogs.com/panpan61803/p/10978117.html
标签:5.0,CentOS,LIBRARY,export,usr,install,PATH,OCR,local From: https://www.cnblogs.com/panpan95/p/16643142.html