LoginSignup
5
3

More than 5 years have passed since last update.

AmazonLinuxにtesseract-ocrをインストールする時にハマった

Last updated at Posted at 2018-03-02

この記事について

  • pyocrでtesseract-ocrを使いたく、Amazon Linuxにtesseract-ocrをインストールしようとしたが、、
  • 少しハマった。ので下記にメモ
  • 結局、下記でyumで普通にインストールできました。。

結論

  • yumの参照リポが、amzn-main になっているので、インストール時に epel を見るようにする。
  • 下記で、tesseractと英語、日本語言語パックがインストールされる
  • あとは、pyocrから叩くなり、そのまま使うなり、お好きにどうぞw
# 前提ライブラリインストール
$ sudo yum --enablerepo=epel --disablerepo=amzn-main install libwebp

# tesseractと言語パックをインストール
$ sudo yum --enablerepo=epel install tesseract tesseract-en tesseract-langpack-jpn

手動インストール手順(yumで入れるなら不要な手順)

  • 以下、epelに気づくまでに、手動でコンパイルしようとした時の作業メモです。
  • yumでインストールするなら 不要な手順 です。
  • 何の役に立つかわかりませんが、一応残しておきます。。

前提環境の導入

  • 公式HPに記載の手順で実施する。
  • 前提環境は下記
    • A compiler for C and C++: GCC or Clang
    • GNU Autotools: autoconf, automake, libtool
    • autoconf-archive
    • pkg-config
    • Leptonica
    • libpng, libjpeg, libtiff
  • autoconf-archive がyumでインストールできないので、自力コンパイル
$ wget http://ftp.jaist.ac.jp/pub/GNU/autoconf-archive/autoconf-archive-2017.09.28.tar.xz
$ tar xvf autoconf-archive-2017.09.28.tar.xz
$ cd autoconf-archive-2017.09.28
$ ./configure && make && make install 
  • で、ハマったのが、この手順。make installだけじゃなく、下記のコピーが必要!(★重要★)
# copy the generated macros to /usr/share/aclocal/, such that autogen.sh can find them
$ cp ./m4/* /usr/share/aclocal/

tesseract-ocrのコンパイル

  • あとは、手順通りインストールすれば導入可能
$ git clone https://github.com/tesseract-ocr/tesseract.git tesseract-ocr
$ cd tesseract-ocr
$ ./autogen.sh
$ make && make install

★重要★の手順を実施しないと、

  • 下記のように、configureの AX_CHECK_COMPILE_FLAG(-mavx, avx=true, avx=false) でエラーとなる。
$ ./configure
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
Using git revision: 4.00.00dev-728-g40f43111
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking whether make supports nested variables... yes
checking dependency style of g++... gcc3
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
./configure: line 4201: syntax error near unexpected token `-mavx,'
./configure: line 4201: `AX_CHECK_COMPILE_FLAG(-mavx, avx=true, avx=false)'
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3