在opencv3.0以上的版本中,无法使用xfeature2d等模块,比如,在安装编译DBOW2的我时候,在DVision中的surfset源文件中就包含<opencv2/xfeature2d/nonfree.hpp>头文件,但是如果只安装了opencv3.0及其以上的版本(比如我安装的3.2.0),就无法找到这个头文件,原因是opencv把这些不稳定的模块发布了opencv_contrib中,这个额外的opencv_contrib是需要重新下载编译安装的。
于是就满怀期待的去opencv_contrib的github官网上下载了,并且按照readme上面的提示安装编译,然而在cmake的时候总是出现这样的错误:
Downloading ...
CMake Error at /Users/Documents/opencv/source/opencv-3.2.0/cmake/OpenCVUtils.cmake:1045 (file):
file DOWNLOAD cannot open file for write.
Call Stack (most recent call first):
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/CMakeLists.txt:5 (include)CMake Error at /Users/Documents/opencv/source/opencv-3.2.0/cmake/OpenCVUtils.cmake:1049 (message):
Failed to download . Status=
Call Stack (most recent call first):
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/cmake/OpenCVFindLibProtobuf.cmake:32 (ocv_download)
/Users/Documents/opencv/source/opencv_contrib-master/modules/dnn/CMakeLists.txt:5 (include)
解决办法参照参照了issue,原因应该是直接在https://github.com/opencv/opencv_contrib这里现在的contrib里面的配置参数不是最新的,到时下载一些依赖包的时候不成功,最新的是:https://github.com/opencv/opencv_contrib/archive/3.2.0.zip
下载后重新cmake
cd software/opencv-3.2.0/release
cmake -DOPENCV_EXTRA_MODULES_PATH=/home/zxw/software/opencv-3.2.0/opencv_contrib-3.2.0/modules ..
make
sudo make install