LoginSignup
60
30

More than 5 years have passed since last update.

Raspbian Liteでビルド済みのOpenCVパッケージを使うための依存パッケージいろいろ

Posted at

Raspbian Liteでビルド済みのOpenCV 3.xパッケージ(正確に言うとPythonパッケージ)を使おうとしたら地味に辛かったのでメモしておきます。

良い子はおとなしくOpenCV 2.4でも使ってなさいってことなのか。

GUIつきのRaspbianまたは普通にインストールしたUbuntuなどではここまで面倒ではないと思います。

contribにある二値化処理アルゴリズムを試したかっただけなのに。コマンド一発の代償は大きいのかどうか。

Python以外からOpenCVを使わない、という前提です。C++でやりたい人は素直にコンパイルしましょう。

ビルト済みパッケージのインストール

下記のPythonパッケージをインストールするとcontribつきのOpenCVバイナリがついてきます。
おもちゃのついたラムネ菓子、いわゆる食玩みたいなものです。

$ pip install opencv-contrib-python

または

$ pip install opencv-contrib-python-headless

Pythonから使う場合は以下のように。

import cv2

と、いいたいところですがまあ動かないでしょう。おそらく。

Raspbian Liteの場合は必要なパッケージがインストールされておらず、APT経由でないので自動的にはインストールされません。

エラーと対応するパッケージ名のリスト

実際はいろいろとライブラリが見つからないというエラーが表示される。

カッコ内はソースからビルドするときに必要になりそうなパッケージ。

HDF5

ImportError: libhdf5_serial.so.100: cannot open shared object file: No such file or directory

-> libhdf5-100 (libhdf5-serial-dev)

HarfBuzz

ImportError: libharfbuzz.so.0: cannot open shared object file: No such file or directory

-> libharfbuzz0b (libharfbuzz-dev)

WebP

ImportError: libwebp.so.6: cannot open shared object file: No such file or directory

-> libwebp6 (libwebp-dev)

Jasper

ImportError: libjasper.so.1: cannot open shared object file: No such file or directory

-> libjasper1 (libjasper-dev)

???

ImportError: libImath-2_2.so.12: cannot open shared object file: No such file or directory

-> libilmbase12 (libilmbase-dev)

OpenEXR

ImportError: libIlmImf-2_2.so.22: cannot open shared object file: No such file or directory

-> libopenexr22 (libopenexr-dev)

Gstreamer

ImportError: libgstbase-1.0.so.0: cannot open shared object file: No such file or directory

-> ibgstreamer1.0-0 (libgstreamer1.0-dev)

FFmpeg関連

ImportError: libavcodec.so.57: cannot open shared object file: No such file or directory

-> libavcodec-extra57 (libavcodec-dev)

ImportError: libavformat.so.57: cannot open shared object file: No such file or directory

-> libavformat57 (libavformat-dev)

ImportError: libswscale.so.4: cannot open shared object file: No such file or directory

-> libswscale4 (libswscale-dev)

Gtk3

ImportError: libgtk-3.so.0: cannot open shared object file: No such file or directory

-> libgtk-3-0 (libgtk-3-dev)

Qt関連

headlessの場合は不要。

ImportError: libQtGui.so.4: cannot open shared object file: No such file or directory

-> libqtgui4 (libqt4-dev)

ImportError: libQtTest.so.4: cannot open shared object file: No such file or directory

-> libqt4-test

コピー用のリスト

sudo apt install libhdf5-100
sudo apt install libharfbuzz0b
sudo apt install libwebp6
sudo apt install libjasper1
sudo apt install libilmbase12
sudo apt install libopenexr22
sudo apt install libgstreamer1.0-0
sudo apt install libavcodec-extra57
sudo apt install libavformat57
sudo apt install libswscale4
sudo apt install libgtk-3
sudo apt install libgtk-3-0
sudo apt install libqtgui4
sudo apt install libqt4-test

まとめ

需要があるのか著しく疑問ですが、せっかくなので。

不足があったらコメントで指摘してもらえると(どこかの誰かが)助かります。

60
30
1

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
60
30