赞
踩
(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安装:
- brew install automake autoconf libtool
- brew install pkgconfig
- brew install icu4c
- brew install leptonica
- brew install gcc
brew install pango
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.
- 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)。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。