Skip to content

Instantly share code, notes, and snippets.

@angelorodem
Last active February 28, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelorodem/4633f1d04f0a80ba4a195853a179f7f7 to your computer and use it in GitHub Desktop.
Save angelorodem/4633f1d04f0a80ba4a195853a179f7f7 to your computer and use it in GitHub Desktop.
# Installing most of opencv features on ubuntu 18 or 16 with cuda (optinal)
(this is not a tutorial, you must know how to use cmake and make)
# Update you packet manager (sudo apt update)
# Choose a operating system and run the apt install for it
# You may find duplicate packeges, it's because its a compilation of other tutorials
# Ubuntu 18.04 OR 18.10
sudo apt-get update
sudo apt install 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 gcc-6-x86-64-linux-gnu-base 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
##
# Ubuntu 16
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install 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
##
# If you want Intel MLK (good if using CPU workload) follow this tutorial https://gist.github.com/pachamaltese/afc4faef2f191b533556f261a46b3aa8
# If on ubuntu 18 configure to use gcc-6 as default gcc with, this is because of the CUDA version, if you install other cuda version, check the supported version and then download and change this command
# This tutorial uses cuda 9, cuda 10 uses higher versions but it is still compatible with version 6 of gcc
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 100
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 100
update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-6 100
# Install ceres solver (Google lib)
git clone https://ceres-solver.googlesource.com/ceres-solver
cd ceres-solver
mkdir build && cd build
cmake ..
make -j4
make test
sudo make install
# If you want a good tutorial on installing CUDA, just follow tensorflow GPU tutorial, (but mind the versions needed by opencv and tensorflow), cuda version 9 is safe
# Install nvidia driver via ubuntu additional drivers
# Install cuda 9.0 **without the driver** and using --override (Linux run file)
# Install cudNN 7.0.5
# this cuda and cudNN version and installing procedure are compatible with Tensorflow GPU, but you'll still need to follow the tutorial for installing cuda cmd line and stuff...
# Download the lastest *opencv* release and the *opencv contrib* release that matches the opencv release (https://github.com/opencv/opencv_contrib) *don't* use opencv master, its usually broken
# Use cmake-gui, enable TBB, QT, FAST_MATH (cuda_fast_math too) and non-free, point the EXTRAS folder to the contrib modules folder, disable PRECOMPILED_HEADERS and disable FFMPEG if using remote IP cameras
# check the advanced checkbox on cmake-gui
# put this
# --expt-relaxed-constexpr
# in CUDA_NVCC_FLAGS
# ***Not recommended***
# you can improve opencv performance by changing the CMAKE_CXX_RELEASE_FLAGS and CMAKE_C_RELEASE_FLAGS with this
# -Ofast -DNDEBUG -mtune=native -march=native -mfpmath="387+sse" -fmodulo-sched -fmodulo-sched-allow-regmoves
# Its supposed to be faster but i would not trust the stability (it also makes the binaries optized for your processor arch, it may cause problems with other PCs)
# Click on generate
# To build go build folder and run:
# make -j (number of processor cores)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment