Created
October 17, 2017 13:24
-
-
Save dtcarls/04b22c38e1d40189efe7abf934f43c8f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
##### Source: https://www.learnopencv.com/install-opencv3-on-ubuntu/ | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get remove x264 libx264-dev -y | |
## Step 2.2: Install dependencies | |
sudo apt-get install build-essential checkinstall cmake pkg-config yasm gfortran git -y | |
sudo apt-get install libjpeg8-dev libjasper-dev libpng12-dev -y | |
# If you are using Ubuntu 16.04 | |
sudo apt-get install libtiff5-dev -y | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev -y | |
sudo apt-get install libxine2-dev libv4l-dev -y | |
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev -y | |
sudo apt-get install libqt4-dev libgtk2.0-dev libtbb-dev -y | |
sudo apt-get install libatlas-base-dev -y | |
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev -y | |
sudo apt-get install libvorbis-dev libxvidcore-dev -y | |
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev -y | |
sudo apt-get install x264 v4l-utils -y | |
## Step 2.3: Optional dependencies | |
sudo apt-get install libprotobuf-dev protobuf-compiler -y | |
sudo apt-get install libgoogle-glog-dev libgflags-dev -y | |
sudo apt-get install libgphoto2-dev libeigen3-dev libhdf5-dev doxygen -y | |
## Step 3: Install Python libraries | |
sudo apt-get install python-dev python-pip python3-dev python3-pip | |
sudo -H pip2 install -U pip numpy | |
sudo -H pip3 install -U pip numpy | |
sudo pip3 install numpy scipy matplotlib scikit-image scikit-learn ipython | |
## Step 4: Download OpenCV and OpenCV_contrib | |
git clone https://github.com/opencv/opencv.git | |
cd opencv | |
git checkout 3.3.0 | |
cd .. | |
git clone https://github.com/opencv/opencv_contrib.git | |
cd opencv_contrib | |
git checkout 3.3.0 | |
cd .. | |
cd opencv | |
mkdir build | |
cd build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D INSTALL_C_EXAMPLES=ON \ | |
-D INSTALL_PYTHON_EXAMPLES=ON \ | |
-D WITH_TBB=ON \ | |
-D WITH_V4L=ON \ | |
-D WITH_QT=ON \ | |
-D WITH_OPENGL=ON \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | |
-D BUILD_EXAMPLES=ON .. | |
make -j`nproc` | |
sudo make install | |
sudo sh -c 'echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf' | |
sudo ldconfig | |
cd /usr/lib/python3.5/site-packages/ | |
sudo ln -s /usr/local/lib/python3.5/dist-packages/cv2.cpython-36m-x86_64-linux-gnu.so cv2.so | |
### Test and validate | |
python3 | |
import cv2 | |
print(cv2.__version__) | |
quit() | |
# If OpenCV3 is installed correctly,above command should give output 3.3.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment