基于debian stretch镜像
创建容器
$ docker run --name tesseract_base -d -i -v /root:/root debian
进入容器
$ docker exec -it tesseract_base bash
替换apt源
用下面内容替换/etc/apt/sources.list
文件内容
deb http://mirrors.aliyun.com/debian stretch main contrib non-free
deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free
deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free
deb http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main contrib non-free
更新
apt-get update
安装开发工具
apt-get -y install gcc g++ make cmake autoconf automake libtool pkg-config
安装插件
所有的插件都是可选的,建议全部都安装,这样tesseract就可以支持更多的图片格式
libjpeg
安装依赖nasm
apt-get install nasm
下载地址http://www.linuxfromscratch.org/blfs/view/systemd/general/libjpeg.html
编译libjpeg
tar -xvf libjpeg-turbo-2.0.2.tar.gz
cd libjpeg-turbo-2.0.2
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_STATIC=FALSE -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/libjpeg-turbo-2.0.2 -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib ..
make
make install
ldconfig
libpng
安装依赖zlib
下载地址 http://www.zlib.net/fossils/
tar -zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make -j 8
make install
ldconfig
下载地址 http://www.linuxfromscratch.org/blfs/view/systemd/general/libpng.html
编译
tar -xvf libpng-1.6.37.tar.xz
cd libpng-1.6.37
./configure --prefix=/usr --disable-static
make -j8
make install
ldconfig
giflib
安装依赖 xmlto
apt-get install xmlto
giflib 下载地址 http://www.linuxfromscratch.org/blfs/view/systemd/general/giflib.html
编译giflib
tar -xvf giflib-5.1.8.tar.gz
cd giflib-5.1.8
make
make install
ldconfig
libtiff
下载地址 http://www.linuxfromscratch.org/blfs/view/systemd/general/libtiff.html
编译
tar -xvf tiff-4.0.10.tar.gz
cd tiff-4.0.10
mkdir cmake-build
cd cmake-build
cmake -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/libtiff-4.0.10 -DCMAKE_INSTALL_PREFIX=/usr ..
make -j8
make install
ldconfig
openjpeg
下载地址 http://www.linuxfromscratch.org/blfs/view/systemd/general/openjpeg2.html
编译openjpeg
tar -xvf openjpeg-2.3.1.tar.gz
cd openjpeg-2.3.1
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_STATIC_LIBS=OFF ..
make
make install
ldconfig
libwebp
先安装好上面的插件,再安装libwebp
下载地址 http://www.linuxfromscratch.org/blfs/view/systemd/general/libwebp.html
编译
tar -xvf libwebp-1.0.2.tar.gz
cd libwebp-1.0.2
./configure --prefix=/usr/local --enable-libwebpmux --enable-libwebpdemux --enable-libwebpdecoder --enable-libwebpextras --enable-swap-16bit-csp --disable-static
make -j8
make install
ldconfig
安装依赖leptonica
官网http://www.leptonica.com/
要求Leptonica 1.74或者更高版本
下载地址 http://www.leptonica.com/download.html
或者GitHub https://github.com/DanBloomberg/leptonica/releases
这里我们下载最新版本的1.78
tar -xvf leptonica-1.78.0.tar.gz
cd leptonica-1.78.0
./configure
make -j8
make install
ldconfig
安装tesseract
下载地址 https://github.com/tesseract-ocr/tesseract/releases
tar -xvf tesseract-4.0.0.tar.gz
cd tesseract-4.0.0/
./autogen.sh
./configure --prefix=/usr
make -j8
make install
ldconfig
验证
$ tesseract --version
tesseract 4.0.0
leptonica-1.78.0
libgif 5.1.8 : libjpeg 6b (libjpeg-turbo 2.0.2) : libpng 1.6.37 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.2 : libopenjp2 2.3.1
Found AVX
Found SSE
原文地址:https://www.cnblogs.com/yanhai307/p/10791490.html