Hello, today we’ll install the OpenCV library on the Ubuntu 14.04 operation system. We need the installed CUDA 7.5 (we have done it in the previous post). First, we have to update our Ubuntu system. Open your terminal and execute:
1 |
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove |
Then we need to install the dependencies: Build tools:
1 |
sudo apt-get install build-essential cmake |
GUI:
1 |
sudo apt-get install qt5-default libvtk6-dev |
Media I/O:
1 |
sudo apt-get install zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev |
Video I/O:
1 |
sudo apt-get install libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264- dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev |
Parallelism and linear algebra libraries:
1 |
sudo apt-get install libtbb-dev libeigen3-dev |
Python:
1 |
sudo apt-get install python-dev python-tk python-numpy python3-dev python3-tk python3-numpy |
Java:
1 |
sudo apt-get install ant default-jdk |
Documentation:
1 |
sudo apt-get install doxygen |
Now we have to download the latest version of library for Linux from the OpenCV official website. Then decompress the downloaded file. In your terminal, make sure you are within the OpenCV directory and run the following commands:
1 |
mkdir build && cd build |
Then we should configure our cmake compiler. For my desktop GPU (GTX 980) which has the Maxwell architecture I used -DCUDA_ARCH_BIN=5.2 -DCUDA_ARCH_PTX=5.2:
1 |
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DWITH_CUDA=ON -DCUDA_ARCH_BIN=5.2 -DCUDA_ARCH_PTX=5.2 .. |
For my laptop (820M) which has the Fermi architecture I used -DCUDA_ARCH_BIN=2.0 -DCUDA_ARCH_PTX=2.0:
1 |
cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DWITH_CUDA=ON -DCUDA_ARCH_BIN=2.0 -DCUDA_ARCH_PTX=2.0 .. |
Then we need compile the source with parameter -j4 (cont of threads, it may be higher for you)
1 |
make -j4 sudo make install |
After that, configure OpenCV:
1 |
sudo ldconfig |
Now, you have installed OpenCV.