トップ 差分 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

Diary/2019-5-16

OpenCV 4.0.1

RaspberryPi3 B+,Jetson Nano,Jetson TX2の各種環境でビルド.
それぞれ,

dd if=/dev/zero of=swapfile bs=1M count=2048
sudo mkswap swapfile
sudo swapon swapfile

で,スワップ領域を用意.
必要そうなものをいろいろインストール

sudo apt-get install -y build-essential cmake pkg-config
sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev libjpeg-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libxvidcore-dev libx264-dev
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y libatlas-base-dev gfortran
sudo apt-get install -y python2.7-dev python3-dev
sudo apt-get install -y python-pip python3-pip
sudo pip install numpy
sudo pip3 install numpy

ソースコードを用意して,

wget -O opencv.zip https://github.com/Itseez/opencv/archive/4.0.1.zip
unzip opencv.zip
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/4.0.1.zip
unzip opencv_contrib

RaspberryPi3の場合,

cmake -DCMAKE_BUILD_TYPE=Release \
   -DCMAKE_INSTALL_PREFIX=/usr/local \
   -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1/modules \
   -DENABLE_VFPV3=ON \
   -DENABLE_NEON=ON \
   -DBUILD_TESTS=OFF \
   -DWITH_TBB=OFF \
   -DINSTALL_PYTHON_EXAMPLES=ON \
   -DOPENCV_SKIP_PYTHON_LOADER=ON \
   -DOPENCV_PYTHON2_INSTALL_PATH=/usr/local/lib/python2.7/dist-packages \
   -DOPENCV_PYTHON3_INSTALL_PATH=/usr/local/lib/python3.5/dist-packages \
   -DOPENCV_GENERATE_PKGCONFIG=ON \
   -DBUILD_EXAMPLES=ON \
   ..

Jetson Nano,Jetson TX2の場合,

sudo apt install opencl-headers ocl-icd-libopencl1

を追加でいれて,

cmake -DCMAKE_BUILD_TYPE=Release \
   -DCMAKE_INSTALL_PREFIX=/usr/local \
   -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.0.1//modules \
   -DOPENCV_ENABLE_NONFREE=true \
   -DBUILD_EXAMPLE=ON \
   -DWITH_CUDA=ON \
   -DCUDA_ARCH_BIN=6.2 \
   -DCPU_BASELINE=FP16 \
   ..

として

make
sudo make install

さて,ビルドは成功する,かな?


...RaspberryPi3ではうまくビルドできたけど,
Jetson NanoとJetson TX2はビルド中にディスクが不足して失敗してた.

打合せ

北参道→巣鴨→四谷