安装opencv_contrib(ubuntu16.04)
1.下载opencv_contrib
opencv_contrib的版本根据你的opencv版本而定,记住一点:opencv_contrib的版本与opencv的版本一定要一致!
我的opencv版本是3.4.1。故本篇以opencv_contrib_3.4.1为例
opencv下载地址:https://codeload.github.com/opencv/opencv/zip/3.4.1
opencv_contrib下载地址:https://github.com/opencv/opencv_contrib/archive/3.4.1.zip
下载成功后,将opencv_contrib目录移到opencv目录下。由于我的opencv是早就下载安装好了的,为了免去不必要的麻烦,让opencv和opencv_contrib同步编译安装,所以先卸载opencv。否则,在编译的过程中会出现各种问题……
2. 安装一些依赖的库
1 sudo apt-get install build-essential 2 sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev 3 sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 4 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev 5 sudo apt-get install libxvidcore-dev libx264-dev 6 sudo apt-get install libatlas-base-dev gfortran 7 sudo apt-get install ffmpeg
3. 编译安装opencv和opencv_contrib,进入opencv的安装目录
1 $ mkdir build 2 $ cd build 3 $ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=/home/cc/software/opencv-3.4.1/opencv_contrib-3.4.1/modules ..
1 sudo make 2 sudo make install
整个安装过程就是这样
可能出现的错误及解决方法:
1.报错:
/home/cc/software/opencv_contrib-3.4.1/modules/xfeatures2d/src/vgg.cpp:490:41: fatal error: vgg_generated_120.i: 没有那个文件或目录
解决方法1:
找到文件:vgg_generated_120.i,然后将其拷贝到/home/cc/software/opencv_contrib-3.4.1/modules/xfeatures2d/src目录下。
其他类似报错根据提示的文件路径也做同样的处理。
需要的文件有:vgg_generated_120.i、vgg_generated_80.i、vgg_generated_64.i、vgg_generated_48.i、boostdesc_bgm.i、boostdesc_bgm_hd.i、boostdesc_bgm_bi.i、boostdesc_lbgm.i、opencv2/xfeatures2d.hpp、opencv2/xfeatures2d/nonfree.hpp、 opencv2/xfeatures2d/cuda.hpp、opencv2/xfeatures2d/cuda.hpp、
有些文件可能找不到,需要自己从网上下载。
解决方法2:
或者多重复几次cmake过程,也许就能下载成功
2.查看CmakeError.log报错: #error "C++11 is not supported"
可能的错误原因是:cmake时的OpenCV_contrib的路径不正确。