Last active
March 17, 2019 15:58
-
-
Save angelorodem/28dbfd3a3eb26dd225127a31359c944b to your computer and use it in GitHub Desktop.
Compile and install opencv automatically with almost all libs contrib, without cuda (Ubuntu 16 and 18)
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
#!/bin/bash | |
i=0 | |
tput sc | |
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do | |
case $(($i % 4)) in | |
0 ) j="-" ;; | |
1 ) j="\\" ;; | |
2 ) j="|" ;; | |
3 ) j="/" ;; | |
esac | |
tput rc | |
echo -en "\r[$j] Waiting for other software managers to finish..." | |
sleep 0.5 | |
((i=i+1)) | |
done | |
version_number="$(lsb_release -r -s)" | |
echo "Your version: $version_number" | |
version=$(echo "$version_number > 17.10" |bc -l) | |
if [ "$version" ];then | |
echo "Ubuntu18" | |
sudo apt-get update | |
sudo apt install unzip cmake curl default-jre tesseract-ocr libtesseract-dev libgphoto2-dev libavresample-dev ffmpeg libgstreamer-opencv1.0-0 gstreamer1.0-libav gstreamer1.0-opencv gstreamer1.0-plugins-base gstreamer1.0-vaapi libgstreamer1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-rtsp gstreamer1.0-plugins-bad libatlas-base-dev libsuitesparse-dev gcc-6 g++-6 libeigen3-dev libgflags-dev libgoogle-glog-dev fonts-powerline git htop libatlas3-base libavcodec-dev libavformat-dev libblas3 libboost-dev libcrypto++-dev libdc1394-22-dev libfaac-dev libffi-dev libgl1-mesa-dev libgstreamer1.0-0-dbg libgstreamer-plugins-base1.0-dev libgtk-3-dev libhdf5-dev libjpeg-dev liblapack-dev libleveldb-dev liblmdb-dev liblog4cpp5-dev libmp3lame-dev libncurses5-dev libomp-dev libopencore-amrnb-dev libopencore-amrwb-dev libpng-dev libprotobuf-dev libpthread-stubs0-dev libpthread-workqueue-dev libsnappy-dev libssl-dev libswscale-dev libtbb-dev libtheora-dev libtiff5-dev libv4l-dev libvlc-dev libx11-dev mesa-utils tightvncserver libboost-all-dev libgtk-3-dev libhdf5-serial-dev vlc build-essential cmake cmake-gui git libgtk2.0-dev pkg-config libdc1394-22 libtiff5-dev libswscale-dev libxine2-dev libqt4-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip qtbase5-dev libgtk-3-dev python-numpy python3-numpy -y | |
elif [ "$version" ]; then | |
echo "Ubuntu16" | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo apt install unzip gcc-6 g++-6 cmake libavresample-dev tesseract-ocr libtesseract-dev libgphoto2-dev curl default-jre libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base1.0-0 libgstreamer1.0 libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk-3-dev ffmpeg gstreamer1.0-libav gstreamer1.0-plugins-base gstreamer1.0-vaapi libgstreamer1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad libatlas-base-dev libsuitesparse-dev libeigen3-dev libgflags-dev libgoogle-glog-dev fonts-powerline git htop libatlas3-base libatlas-base-dev libavcodec-dev libavformat-dev libblas3 libboost-dev libcrypto++-dev libdc1394-22-dev libfaac-dev libffi-dev libgl1-mesa-dev libgstreamer1.0-0-dbg libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk-3-dev libhdf5-dev libjpeg-dev liblapack-dev libleveldb-dev liblmdb-dev liblog4cpp5-dev libmp3lame-dev libncurses5-dev libomp-dev libopencore-amrnb-dev libopencore-amrwb-dev libpng-dev libprotobuf-dev libpthread-stubs0-dev libpthread-workqueue-dev libsnappy-dev libssl-dev libswscale-dev libtbb-dev libtheora-dev libtiff5-dev libv4l-dev libvlc-dev libx11-dev mesa-utils tightvncserver libatlas-base-dev libavcodec-dev libavformat-dev libboost-all-dev libcrypto++-dev libdc1394-22-dev libgstreamer1.0-0-dbg libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk2.0-dev libgtk-3-dev libhdf5-dev libhdf5-serial-dev libjpeg-dev liblapack-dev libleveldb-dev libomp-dev libprotobuf-dev libsnappy-dev libswscale-dev libtiff5-dev vlc build-essential cmake cmake-gui git libgtk2.0-dev pkg-config libdc1394-22 libdc1394-22-dev libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libv4l-dev libqt4-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip qtbase5-dev ffmpeg libgtk-3-dev python-numpy python3-numpy libjasper-dev -y | |
fi | |
git clone https://ceres-solver.googlesource.com/ceres-solver | |
cd ceres-solver | |
mkdir build && cd build | |
cmake .. | |
make -j4 | |
sudo make install | |
cd ../.. | |
wget https://github.com/opencv/opencv/archive/4.0.1.tar.gz | |
tar -xvf 4.0.1.tar.gz | |
cd opencv-4.0.1 | |
wget https://github.com/opencv/opencv_contrib/archive/4.0.1.zip | |
unzip 4.0.1.zip | |
cd .. | |
mkdir opencv_build | |
cd opencv_build | |
cmake \ | |
-DENABLE_PRECOMPILED_HEADERS:BOOL=OFF \ | |
-DBUILD_TBB:BOOL=ON \ | |
-DWITH_TBB:BOOL=ON \ | |
-DENABLE_FAST_MATH:BOOL=ON \ | |
-DWITH_QT:BOOL=ON \ | |
-DOPENCV_ENABLE_NONFREE:BOOL=ON \ | |
-DOPENCV_EXTRA_MODULES_PATH:PATH=../opencv_contrib-4.0.1/modules \ | |
-DCMAKE_CXX_FLAGS_RELEASE:STRING="-Ofast -DNDEBUG -mtune=native -march=native -mfpmath="387+sse" -fmodulo-sched -fmodulo-sched-allow-regmoves" \ | |
../opencv-4.0.1 | |
make -j4 | |
sudo make install | |
cd .. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment