View difference between Paste ID: tQwYGmfs and KLpEdQ4D
SHOW: | | - or go back to the newest paste.
1
#https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/
2
# sudo raspi-config  #use all of the SD card.
3
mydir="/home/pi/lfs"
4
mycores="-j4"
5-
set -euf -o pipefail #sipb.mit.ede safe scripting tutorial
5+
set -euf -o pipefail      #sipb.mit.ede safe scripting tutorial
6
7
function createLFS {
8
 ! [ -d "$mydir" ] &&  mkdir "$mydir"
9
}
10
11
# sudo apt update; sudo apt-get upgrade; sudo rpi-update
12
sudo apt purge wolfram-engine; sudo apt purge libreoffice
13
sudo apt install     -y build-essential git cmake pkg-config
14
sudo apt-get         -y  install python2.7-dev python3-dev
15
sudo apt install     -y  libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev
16
sudo apt-get install -y  libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
17
sudo apt install     -y  libavutil-dev  libavdevice-dev
18
sudo apt-get install -y libxvidcore-dev libx264-dev
19
sudo apt-get install -y libgtk2.0-dev
20
sudo apt-get install -y libatlas-base-dev gfortran
21
wget -nc https://bootstrap.pypa.io/get-pip.py; sudo python get-pip.py
22
sudo pip2 install  numpy
23
sudo pip3 install  numpy
24
25
cd "$mydir"
26-
wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
26+
# files copied over already into lfs folder
27-
unzip opencv_contrib.zip
27+
#wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
28
#unzip opencv_contrib.zip
29
30
################# SET SWAPFILE SIZE ##############	
31
# cd /etc/dphys-swapfile 
32
# https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/
33
# edit file 
34-
# sudo /etc/init.d/dphys-swapfile swapoff
34+
35-
# sudo /etc/init.d/dphys-swapfile swapon
35+
# sudo /etc/dphys-swapfile swapoff
36
# sudo /etc/dphys-swapfile swapon
37-
git clone https://github.com/opencv/opencv.git
37+
38
#git clone https://github.com/opencv/opencv.git
39-
git checkout 3.3.0
39+
40
#git checkout 3.3.0
41
git checkout master
42
git pull 
43
# rm -rf build
44
mkdir build && cd build
45
cmake -D CMAKE_BUILD_TYPE=RELEASE \
46
      -D CMAKE_INSTALL_PREFIX=/usr/local \
47
      -D OPENCV_EXTRA_MODULES_PATH="$mydir/opencv_contrib-3.3.0/modules" \
48
      -D BUILD_TESTS=OFF  ..
49
#      -D INSTALL_PYTHON_EXAMPLES=ON \
50
#      -D BUILD_EXAMPLES=ON ..
51
#      -D PYTHON_EXECUTABLE=/usr/bin/python3.5 \
52
#      -D PYTHON_PACKAGES_PATHS=/usr/local/lib/python3.5/dist-packages \
53
#      -D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include ..  \
54
#      -D ENABLE_NEON=ON \
55
#      -D ENABLE_VFPV3=ON \
56
57
make -j4; sudo make install; sudo ldconfig
58
#go back to swap file reset to 100mb! 
59
60
function post_install_opencv {
61
if [ ! -e "/etc/ld.so.conf.d/opencv.conf" ]; then
62
 sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf'
63
fi
64
sudo ldconfig
65
echo "finding the cv2.so package at usr/local/lib"
66
find /usr/local/lib/ -type f -name "cv2*.so"
67
# outputs
68
#/usr/local/lib/python2.7/dist-packages/cv2.so
69
#/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-x86_64-linux-gnu.so
70
#cd /usr/local/lib/python3.5/dist-packages
71
echo "moving(renaming) the x86 cv2 file to cv2.so"
72
cd /usr/local/lib/python3.5/dist-packages
73
sudo mv cv2.cpython-35m-x86_64-linux-gnu.so cv2.so
74
#ln -s /usr/local/lib/python3.5/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so cv2.so
75
}
76
 
77
78
#https://www.pyimagesearch.com/2016/04/18/install-guide-raspberry-pi-3-raspbian-jessie-opencv-3/ 
79
# make certain that cv2.so in site packages are in both python2 and 3 . See web for details.