編譯可訓練的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)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章