The following blog posts are mainly referred to:
1, http://blog.csdn.net/redmoon729/article/details/69986131
Ubuntu16.04 under Installation Opencv3
2, http://blog.csdn.net/huangkangying/article/details/53406370
OpenCV 3.1 Download ippicv_linux_20151201 failed
3, http://blog.csdn.net/scutjy2015/article/details/78662021
ubuntu16.04 full make installation OpenCV 3.2.0 First, ubuntu uninstall OpenCV step
Go to the Build folder, and the command line executes the following command. This step can be skipped, such as a new installation.
Make uninstall
CD
. sudo rm-r build
sudo rm-r/usr/local/include/opencv2/usr/local/include/opencv/usr/include/opencv/usr/include/ opencv2/usr/local/share/opencv/usr/local/share/opencv/usr/share/opencv/usr/share/opencv/usr/local/bin/opencv*/ usr/local/lib/libopencv*
Second, install the related dependent library
(The dependent library must be loaded)
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install Libjpeg8-dev libt Iff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev< C3/>sudo apt-get Install Libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install Libatlas-base-dev gfortran
sudo apt-get install python3.5-dev
sudo apt-get install FFmpeg
third, prepare for IPPICV
Downloading ippicv_2017u3_lnx_intel64_general_20170822.tgz during installation is a long time and even download fails. IPPICV is a parallel computing library that can in fact not be installed. If you do not want to install just add the following option when you configure CMake in the following step four:
-D with_ipp=off \
Here, the installation is still selected for protection against subsequent needs. Search on the CSDN, a netizen has provided the download file. After downloading, create a script file in the directory where the file ippicv_2017u3_lnx_intel64_general_20170822.tgz, the content is as follows, where the path needs to be modified according to your actual situation. Create the Downloads folder under opencv-3.3.1/3rdparty/ippicv/. Then execute the script.
#!/bin/bash
ipp_file=./ippicv_2017u3_lnx_intel64_general_20170822.tgz &&
ipp_hash=$ (md5sum $ipp _file | Cut-d ""-f1) &&
ipp_dir=/home/xxx/downloads/opencv-3.3.1/3rdparty/ippicv/downloads/linux-$ipp _ Hash &&
mkdir-p $ipp _dir &&
cp $ipp _file $ipp _dir
Executing the above script, a folder similar to the name linux-4e0352ce96473837b1d671ce87f17359 will be generated under opencv-3.3.1/3rdparty/ippicv/downloads/. The numbers may vary and do not affect them. The folder is already copied ippicv_2017u3_lnx_intel64_general_20170822.tgz file four: Compile and install opencv3.3.1
Go to the opencv3.3.1 unzipped folder, and then CMake configure the properties, execute the following command:
$ cd opencv-3.3.1
$ mkdir Build
$ cd build
cmake-d cmake_build_type=release \
d cmake_install_prefix=/ HOME/XXX/ANACONDA3 \-
d install_python_examples=on \-
d install_c_examples=off \-
D python_excutable=/ Home/xxx/anaconda3/bin/python \-
d with_tbb=on \-
d with_v4l=on \-
d with_qt=on \-
d with_gtk=on \
-D with_opengl=on \-
d build_examples=on.
which
Cmake_install_prefix: The python directory prefix installed, in fact, specifies the installation path of the Python module. The output of the following command is the path:
Python-c "Import sys; Print (Sys.prefix) "
Python_excutable: Specifies the executable file path for Python. The output of the following command is the path
which Python
If you want to turn off IPPICV installation, simply add a line to the CMake command above:-D with_ipp=off \ Can
After successful execution of the above configuration command, continue to execute the compile command
Make-j15
Where-JX is multi-threaded using the CPU, X is the number of threads to use. My CPU is AMD Ryzen 1700X (8 core 16 threads), so this is configured as-j15, using 15 threads, the following figure is the CPU usage during the execution. Configuring multithreading can greatly shorten compilation time.
Execute the Install command
sudo make install
Add to Dynamic link library
sudo ldconfig
v. Verification TEST:
Execute the following command:
Python-c "Import Cv2; Print (cv2.__version__) "
The OPENCV version number that is already installed is normally output
3.3.1
Continue import CV2 Test
Python python
3.6.3 | Anaconda, inc.| (Default, OCT, 12:02:49)
[GCC 7.2.0] on Linux
Type ' help ', ' copyright ', ' credits ' or ' license ' for more information.
>>> Import Cv2
>>>
Successful import error-free.
This opencv3.3.1 installation is successful.