【干货】centos下搭建图像文字识别
共 1468字,需浏览 3分钟
·
2022-05-23 18:36
下载
wget https://github.com/tesseract-ocr/tesseract/archive/4.1.0.tar.gz
leptnica下载地址:https://gitee.com/mirrors/leptonica.git
安装依赖:yum install autoconf automake libtool libjpeg-devel libpng-devel libtiff-devel zlib-devel gcc gcc-c++ gcc-g77
安装leptonica
tar -xzvf leptonica-1.74.4.tar.gz
cd leptonica-1.74.4
./autobuild
./configure --prefix=/usr/local/leptonica
make
sudo make install
配置一下 leptonica 的环境变量。
打开 /etc/profile
vim /etc/profile
添加以下字段
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/leptonica/lib/pkgconfig
export PKG_CONFIG_PATH
CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/local/leptonica/include/leptonica
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/leptonica/lib
export LD_LIBRARY_PATH
LIBRARY_PATH=$LIBRARY_PATH:/usr/local/leptonica/lib
export LIBRARY_PATH
LIBLEPT_HEADERSDIR=/usr/local/leptonica/include/leptonica
export LIBLEPT_HEADERSDIR
应用配置
source /etc/profile
OK,现在我们就可以开始安装 tesseract。
安装 tesseract
tar -xzvf 4.1.0.tar.gz
cd tesseract-4.1.0
./autogen.sh
./configure --prefix=/usr/local/tesseract
make
sudo make install
接下来配置 tesseract 环境变量
打开 /etc/profile
vim /etc/profile
追加以下字段
PATH=$PATH:/usr/local/tesseract/bin
export PATH
应用配置
source /etc/profile
测试一下:
tesseract -v
上传 tesseract训练数据
下载地址:https://gitee.com/superaskar/tessdata.git
解压所有文件到/usr/local/tesseract/share/tessdata目录下
测试 tesseract
上传一张图片到/opt/tools目录,并进入该目录,然后输入命令
tesseract t1.png t1opt -l chi_sim