ubuntu22.04编译安装tesseract

发布于:2024-06-29 ⋅ 阅读:(14) ⋅ 点赞:(0)

1、 为什么用自己编译安装,而不采用apt安装?

        由于tesseract有很多依赖包,直接用deb包或者rpm包等安装包安装很复杂,不一定能成功安装。

2、安装基本的依赖包

sudo apt update
sudo apt install g++ autoconf automake libtool pkg-config libpng-dev libjpeg-dev libtiff-dev zlib1g-dev

3、如果需要训练模型,则需要额外安装如下库
 

sudo apt-get install libicu-dev
sudo apt-get install libpango1.0-dev
sudo apt-get install libcairo2-dev

3、安装Leptonica(必须安装的,tesseract需要)

#编译出的最终结果安装在/opt/leptonica-root/install(为了今后卸栽方便)

#以root身份执行,如不是root用户,必须sudo
 

cd /opt
mkdir leptonica-root
cd leptonica-root
mkdir install
git clone https://github.com/DanBloomberg/leptonica.git ./source 
cd source
autoreconf -vi
./configure -prefix=/opt/leptonica-root/install
make -j16
make install

#配置环境

在/etc/ld.so.conf.d下新增一个文件:

vim /etc/ld.so.conf.d/lept-1-84-2.conf


写入以下内容:
 

/opt/leptonica-root/install/lib

4、安装tesseract

cd /opt
mkdir tesseract-root && cd tesseract-root
mkdir install
git clone https://github.com/tesseract-ocr/tesseract.git ./source
cd source/
./autogen.sh 
./configure --prefix=/opt/tesseract-root/install
make -j16
make install

#配置环境

cp /opt/tesseract-root/install/lib/pkgconfig/tesseract.pc /usr/local/lib/pkgconfig
ln -sf /opt/tesseract-root/install/include/tesseract /usr/local/include/tesseract
ln -sf /opt/tesseract-root/install/lib/libtesseract.so /usr/local/lib/libtesseract.so


#查看版本

tesseract --version
pkg-config --modversion tesseract

5、下载语言包

cd /opt/tesseract-root/install/share/tessdata
git clone https://github.com/tesseract-ocr/tessdata_best.git

HI,我是Remon,CSDN上的别名:AncleLeen(被csdn强迫更名),一位30年的老码农了。

VX:RemonLin,敬请备注:cvDNN。VX扫一扫:


网站公告

今日签到

点亮在社区的每一天
去签到