2017年12月26日火曜日

An installation shell script of openCV3.4.0

Raspberry Pi3
Stretch
3時間41分

バージョンの確認は、、、

/usr/local/bin/opencv_version
3.4.0

Peace!!

---------------------------------------------------------------

#! /bin/bash

date;

if [[ `lsb_release -d` =~ .*Raspbian.* ]]
then
        echo "";
        read -p " Continue installing OpenCV (y/n) ? " CONTINUE
        if [[ "$CONTINUE" == "y" || "$CONTINUE" == "Y" ]]; then
                echo "";
                echo "Installing OpenCV";
                echo "";
                sudo apt-get update -y && sudo apt-get upgrade -y
                sudo apt-get install -y build-essential cmake pkg-config
                sudo apt-get install -y libjpeg-dev libtiff5-dev libjasper-dev libpng12-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 libgtk-3-dev
                sudo apt-get install -y libatlas-base-dev gfortran
                sudo apt-get install -y python2.7-dev python3-dev

                cd ~
                wget -O opencv.zip https://github.com/opencv/opencv/archive/3.4.0.zip
                unzip opencv.zip
                wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/master.zip
                unzip opencv_contrib.zip
                                mv ~/opencv_contrib-master ~/opencv_contrib-3.4.0
                cd ~/opencv-3.4.0/
                mkdir build
                cd build
                cmake -D CMAKE_BUILD_TYPE=RELEASE \
                      -D CMAKE_INSTALL_PREFIX=/usr/local \
                      -D INSTALL_PYTHON_EXAMPLES=OFF \
                      -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.0/modules \
                      -D BUILD_EXAMPLES=OFF ..
                make
                sudo make install
                sudo ldconfig
        else
                echo "";
                echo "Skipping OpenCV installation";
                echo "";
        fi
else
        echo "Installing opencv python for non-Raspbian";
        sudo -H pip3 install opencv-python
        sudo -H pip3 install opencv-contrib-python
fi
date;

0 件のコメント:

コメントを投稿