The method of compiling and installing opencv under ubuntu
Easy to install opencv2:
Conda install-- channel https://conda.anaconda.org/menpo opencv
Or:
Sudo apt-get install libopencv-dev python-opencv
Easy to install opencv3:
Pip install opencv-python
Or:
Pip install opencv-python==3.1.0
The simple installation method is to install the compiled Opencv from the library. This installation method is simple and convenient, but the disadvantage is that it is easy to appear unknown bug in use, such as unable to imshow images, unable to read video files, etc. (opencv3 seems to be better).
It is recommended to use source code compilation and installation.
Source code compilation and installation of Opencv2 or Opencv3
1. Install dependent files
Sudo apt-get install build-essentialsudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-devsudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
two。 Download the source package
Download address on the official website: https://opencv.org/opencv-3-2.html
Choose to download tar.gz files for all platforms on the GitHub source (download link: https://github.com/opencv/opencv/archive/3.2.0.tar.gz), opencv-3.2.0.tar.gz, file size 75MB
3. Extract the source code and compile and install
Tar xvf opencv-3.2.0.tar.gzcd opencv-3.2.0mkdir buildcd buildcmake-D CMAKE_BUILD_TYPE=Release-D CMAKE_INSTALL_PREFIX=/usr/local.. makesudo make install
Note: when executing the cmake instruction, you need to download an ippicv_linux_20151201.tgz file. If the network is not good, it may get stuck in:
ICV: Downloading ippicv_linux_20151201.tgz...
At this point, you can download the ippicv_linux_20151201.tgz file separately (file size 36.5MB, download link: https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz), download it and put it in the'/ opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/' folder and re-cmake it.
Summary
The above is the whole content of this article. I hope the content of this article has a certain reference and learning value for everyone's study or work. Thank you for your support. If you want to know more about it, please see the relevant links below.