Forked from austince/install-opencv3.3.1-ubuntu-16.04.sh
Last active
April 17, 2018 10:45
-
-
Save flyudvik/839c0b7ad9c1ca2a2ecfc995cbb45362 to your computer and use it in GitHub Desktop.
OpenCV
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
# Open CV 3.3.1 with python ${VERSION} | |
PYTHON_EXECUTABLE_PATH=$1 | |
if [-z "$PYTHON_EXECUTABLE"] then; | |
echo "Using PATH default python $(command -v python)" | |
PYTHON_EXECUTABLE=$(command -v python) | |
fi | |
set -ex | |
sudo apt-get -y install libtiff5-dev | |
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev | |
sudo apt-get -y install libxine2-dev libv4l-dev | |
sudo apt-get -y install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev | |
sudo apt-get -y install qt5-default libgtk2.0-dev libtbb-dev | |
sudo apt-get -y install libatlas-base-dev | |
sudo apt-get -y install libfaac-dev libmp3lame-dev libtheora-dev | |
sudo apt-get -y install libvorbis-dev libxvidcore-dev | |
sudo apt-get -y install libopencore-amrnb-dev libopencore-amrwb-dev | |
sudo apt-get -y install x264 v4l-utils | |
sudo apt-get -y install -y gcc-5 g++-5 | |
## installation for python bindings | |
sudo apt-get -y install python-pip python3-pip python-dev python3-dev | |
sudo pip install -y virtualenv virtualenvwrapper | |
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc | |
echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc | |
source ~/.bashrc | |
mkvirtualenv cv -p $PYTHON_EXECUTABLE | |
workon cv | |
pip install numpy | |
## Optional | |
sudo apt-get -y install libprotobuf-dev protobuf-compiler | |
sudo apt-get -y install libgoogle-glog-dev libgflags-dev | |
sudo apt-get -y install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen | |
# download opencv-3.3.1 | |
wget https://github.com/opencv/opencv/archive/3.3.1.zip -O opencv-3.3.1.zip | |
unzip opencv-3.3.1.zip | |
# download opencv_corntib-3.3.1 | |
wget https://github.com/opencv/opencv_contrib/archive/3.3.1.zip -O opencv_contrib-3.3.1.zip | |
unzip opencv_contrib-3.3.1.zip | |
cd opencv-3.3.1 | |
mkdir release | |
cd release | |
# compile and install | |
export CC=/usr/bin/gcc-5 | |
export CXX=/usr/bin/g++-5 | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_C_EXAMPLES=ON \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/python \ | |
# -D WITH_TBB=ON \ | |
# -D WITH_V4L=ON \ | |
# -D WITH_QT=ON \ | |
# -D WITH_OPENGL=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.3.1/modules \ | |
-D BUILD_EXAMPLES=ON \ | |
.. | |
# Build with all available cores, leaving for user 1 core. Still be able to create venvs or pull other python packages | |
make "-j$(expr `nproc` - 1 )" | |
# Build with all cores, probablity can't use your computer... | |
# make "-j$(nproc)" | |
sudo make install | |
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf' | |
sudo ldconfig | |
echo "Do not forget to copy cv2.so inside /usr/local/lib/pythonX.Y/site-packages to your local virtualenv env. Should be something like that" | |
echo "sudo ln -s /usr/local/lib/python2.7/site-packages/cv2.so ~/.virtualenvs/cv/lib/site-packages/cv2.so" | |
$PYTHON_EXECUTABLE -c "import cv2; print(cv2.__version__)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment