编译可训练的tesseract时遇到的问题,tesseract-OCR,training-tool

(1)据查https://blog.csdn.net/weixin_39569611/article/details/87278729,今年很早就不能用brew install --with-training-tools tesseract 安装可训练的tesseract了,

 

 

(2)于是自行编译,根据https://github.com/tesseract-ocr/tesseract/wiki/Compiling#macos-with-homebrew 用homebrew安装:

Install dependencies

brew install automake autoconf libtool
brew install pkgconfig
brew install icu4c
brew install leptonica
brew install gcc

Install Tesseract with training tools

brew install pango

Compile

git clone https://github.com/tesseract-ocr/tesseract/
cd tesseract
./autogen.sh
./configure CC=gcc-8 CXX=g++-8 CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib
make -j
sudo make install  # if desired
make training # if installed with training dependencies

(3)如果装不成功,执行一段来自https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00#on-macos-mojave-with-homebrew的命令,也可以提前执行这个命令:

brew install cairo pango icu4c autoconf libffi libarchive
export PKG_CONFIG_PATH=\
$(brew --prefix)/lib/pkgconfig:\
$(brew --prefix)/opt/libarchive/lib/pkgconfig:\
$(brew --prefix)/opt/icu4c/lib/pkgconfig:\
$(brew --prefix)/opt/libffi/lib/pkgconfig
./configure

本人多次尝试,最终是安装成功,能够训练 *.traineddata.

 

(4)出错展示及解决,也即是用(3)中的代码解决了安装(2)时的错误。

git clone https://github.com/tesseract-ocr/tesseract/ 
cd tesseract 
./autogen.sh 
./configure CC=gcc-8 CXX=g++-8 CPPFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib 
make -j 
sudo make install # if desired make training # if installed with training dependencies

但编译时,在./configure**** 这一步出错,错误为:

........

checking for icu-i18n >= 52.1... no

configure: WARNING: icu 52.1 or higher is required, but was not found.

configure: WARNING: Training tools WILL NOT be built.

configure: WARNING: Try to install libicu-devel package.

checking for pango >= 1.22.0... no

configure: WARNING: pango 1.22.0 or higher is required, but was not found.

configure: WARNING: Training tools WILL NOT be built.

configure: WARNING: Try to install libpango1.0-dev package.

checking for cairo... no

configure: WARNING: Training tools WILL NOT be built because of missing cairo library.

configure: WARNING: Try to install libcairo-dev?? package.

checking that generated files are newer than configure... done

configure: creating ./config.status

config.status: creating Makefile

config.status: creating tesseract.pc

..............

config.status: executing libtool commands

 

Configuration is done.

You can now build and install tesseract by running:

 

$ make

$ sudo make install

$ sudo ldconfig

 

Documentation will not be built because asciidoc or xsltproc is missing.

 

You can not build training tools because of missing dependency. (警告中出现的那些找不到的dependency)

Check configure output for details.

 

 

主要是几个警告,导致最后出现You can not build training tools because of missing dependency.

然后按https://stackoverflow.com/questions/55361379/osx-compiling-training-tools-for-tesseract-4-0-pango-libraries-not-found执行

brew install cairo pango icu4c autoconf libffi libarchive
export PKG_CONFIG_PATH=\
$(brew --prefix)/lib/pkgconfig:\
$(brew --prefix)/opt/libarchive/lib/pkgconfig:\
$(brew --prefix)/opt/icu4c/lib/pkgconfig:\
$(brew --prefix)/opt/libffi/lib/pkgconfig
./configure

成功。实际上上段命令来自(3)。

评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值