Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/
- # sudo raspi-config #use all of the SD card.
- mydir="/home/pi/lfs"
- mycores="-j4"
- set -euf -o pipefail #sipb.mit.ede safe scripting tutorial
- function createLFS {
- ! [ -d "$mydir" ] && mkdir "$mydir"
- }
- # sudo apt update; sudo apt-get upgrade; sudo rpi-update
- sudo apt purge wolfram-engine; sudo apt purge libreoffice
- sudo apt install -y build-essential git cmake pkg-config
- sudo apt-get -y install python2.7-dev python3-dev
- sudo apt 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 install -y libavutil-dev libavdevice-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
- wget -nc https://bootstrap.pypa.io/get-pip.py; sudo python get-pip.py
- sudo pip2 install numpy
- sudo pip3 install numpy
- cd "$mydir"
- # files copied over already into lfs folder
- #wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
- #unzip opencv_contrib.zip
- ################# SET SWAPFILE SIZE ##############
- # cd /etc/dphys-swapfile
- # https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/
- # edit file
- # CONF_SWAPSIZE=1024 # set back to 100 after opencv is installed
- # sudo /etc/dphys-swapfile swapoff
- # sudo /etc/dphys-swapfile swapon
- #git clone https://github.com/opencv/opencv.git
- cd opencv
- #git checkout 3.3.0
- git checkout master
- git pull
- # rm -rf build
- mkdir build && cd build
- cmake -D CMAKE_BUILD_TYPE=RELEASE \
- -D CMAKE_INSTALL_PREFIX=/usr/local \
- -D OPENCV_EXTRA_MODULES_PATH="$mydir/opencv_contrib-3.3.0/modules" \
- -D BUILD_TESTS=OFF ..
- # -D INSTALL_PYTHON_EXAMPLES=ON \
- # -D BUILD_EXAMPLES=ON ..
- # -D PYTHON_EXECUTABLE=/usr/bin/python3.5 \
- # -D PYTHON_PACKAGES_PATHS=/usr/local/lib/python3.5/dist-packages \
- # -D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include .. \
- # -D ENABLE_NEON=ON \
- # -D ENABLE_VFPV3=ON \
- make -j4; sudo make install; sudo ldconfig
- #go back to swap file reset to 100mb!
- function post_install_opencv {
- if [ ! -e "/etc/ld.so.conf.d/opencv.conf" ]; then
- sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
- fi
- sudo ldconfig
- echo "finding the cv2.so package at usr/local/lib"
- find /usr/local/lib/ -type f -name "cv2*.so"
- # outputs
- #/usr/local/lib/python2.7/dist-packages/cv2.so
- #/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so
- #cd /usr/local/lib/python3.5/dist-packages
- echo "moving(renaming) the x86 cv2 file to cv2.so"
- cd /usr/local/lib/python3.5/dist-packages
- sudo mv cv2.cpython-35m-x86_64-linux-gnu.so cv2.so
- #ln -s /usr/local/lib/python3.5/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so cv2.so
- }
- #https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/
- # make certain that cv2.so in site packages are in both python2 and 3 . See web for details.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement