-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chong Yoe Yat
committed
Oct 19, 2020
1 parent
4f292f9
commit 74634dd
Showing
5 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
OPENCV_VERSION=4.5.0 | ||
pushd ~/opencv/opencv-$OPENCV_VERSION | ||
mkdir -p build | ||
pushd build | ||
RPI_VERSION=$(awk '{print $3}' < /proc/device-tree/model) | ||
if [[ $RPI_VERSION -ge 4 ]]; then | ||
NUM_JOBS=$(nproc) | ||
else | ||
NUM_JOBS=1 # Earlier versions of the Pi don't have sufficient RAM to support compiling with multiple jobs. | ||
fi | ||
|
||
# -D ENABLE_PRECOMPILED_HEADERS=OFF | ||
# is a fix for https://github.com/opencv/opencv/issues/14868 | ||
|
||
# -D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic | ||
# is a fix for https://github.com/opencv/opencv/issues/15192 | ||
|
||
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | ||
-D CMAKE_INSTALL_PREFIX=/usr/local \ | ||
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-$OPENCV_VERSION/modules \ | ||
-D OPENCV_ENABLE_NONFREE=ON \ | ||
-D BUILD_PERF_TESTS=OFF \ | ||
-D BUILD_TESTS=OFF \ | ||
-D BUILD_DOCS=ON \ | ||
-D BUILD_EXAMPLES=ON \ | ||
-D ENABLE_PRECOMPILED_HEADERS=OFF \ | ||
-D BUILD_TIFF=ON \ | ||
-D WITH_FFMPEG=ON \ | ||
-D WITH_TBB=ON \ | ||
-D BUILD_TBB=ON \ | ||
-D WITH_OPENMP=ON \ | ||
-D ENABLE_NEON=ON \ | ||
-D ENABLE_LTO=ON \ | ||
-D WITH_OPENCL=ON \ | ||
-D WITH_GSTREAMER=ON \ | ||
-D CPU_BASELINE=NEON \ | ||
-D ENABLE_VFPV3=ON \ | ||
-D WITH_OPENGL=ON \ | ||
-D WITH_V4L=ON \ | ||
-D WITH_LIBV4L=ON \ | ||
-D WITH_QT=ON \ | ||
-D OPENCV_EXTRA_EXE_LINKER_FLAGS=-latomic \ | ||
-D CMAKE_SHARED_LINKER_FLAGS=-latomic \ | ||
-D PYTHON3_EXECUTABLE=$(which python3) \ | ||
-D PYTHON_EXECUTABLE=$(which python2) \ | ||
.. | ||
#make -j "$NUM_JOBS" | ||
popd; popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
OPENCV_VERSION=4.5.0 | ||
cd ~ | ||
mkdir -p opencv && pushd opencv | ||
|
||
wget -O "opencv-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.tar.gz" | ||
wget -O "opencv_contrib-${OPENCV_VERSION}.tar.gz" "https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.tar.gz" | ||
tar -xvf "opencv-${OPENCV_VERSION}.tar.gz" | ||
tar -xvf "opencv_contrib-${OPENCV_VERSION}.tar.gz" | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
./download-opencv.sh | ||
|
||
sudo nano /etc/dphys-swapfile | ||
#set CONF_SWAPSIZE=100 to 512 with the Nano text editor | ||
sudo dphys-swapfile setup | ||
sudo /etc/init.d/dphys-swapfile stop | ||
sudo /etc/init.d/dphys-swapfile start | ||
|
||
|
||
# checkinstall to make debian package https://www.theimpossiblecode.com/blog/build-faster-opencv-raspberry-pi3/ | ||
# checkinstall bug https://github.com/opencv/opencv/issues/8897 | ||
git clone https://github.com/giuliomoro/checkinstall | ||
cd checkinstall | ||
sudo make install | ||
|
||
./build-opencv.sh | ||
|
||
make | ||
checkinstall --install=no --pkgname=opencv --pkgversion=4.5.0 --provides=opencv --nodoc --backup=no --exclude=$HOME --requires="devscripts,debhelper,cmake,libldap2-dev,libgtkmm-3.0-dev,libarchive-dev,libcurl4-openssl-dev,intltool,build-essential,cmake,pkg-config,libjpeg-dev,libtiff5-dev,libjasper-dev,libavcodec-dev,libavformat-dev,libswscale-dev,libv4l-dev,libxvidcore-dev,libx264-dev,libgtk2.0-dev,libgtk-3-dev,libatlas-base-dev,libblas-dev,libeigen2-dev,libeigen3-dev,liblapack-dev,gfortran,python2.7-dev,python3-dev,python-pip,python3-pip,python,python3,libgstreamer1.0-dev,libgstreamer-plugins-base1.0-dev,libavresample-dev,libavresample4-dbgsym,libavresample4,qt5-default,tesseract-ocr,libtesseract-dev,libleptonica-dev,libglu1-mesa-dev,freeglut3-dev,mesa-common-dev,liblapacke-dev,libopenblas-dev,libopenblas-base,libgoogle-glog-dev,protobuf-compiler,caffe-cpu" | ||
|
||
#Debian package | ||
sudo dpkg -i opencv_4.5.0-1_armhf.deb | ||
sudo apt-get -f install | ||
sudo dpkg -i opencv_4.5.0-1_armhf.deb | ||
|
||
# Python 3 Check | ||
python3 | ||
import cv2 | ||
|
||
# Python 2 Check | ||
python | ||
import cv2 | ||
|
||
|
||
|
Binary file not shown.