下载源文件:
1.opencv4.1.2下载链接:https://github.com/opencv/opencv
2.opencv_contrib4.1.2下载链接:https://github.com/opencv/opencv_contrib
编译
将解压后的opencv_contrib4.1.2放在opencv4.1.2文件夹下,
新建build文件夹:
mkdir build
进入build文件夹:
cd build
编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv-4.1.2/opencv_contrib/modules/ \
-D OPENCV_ENABLE_NONFREE=ON ../
make
安装:
sudo make install
中间遇到的坑
1.opencv下载过程中,如果一直卡在下载ippicv_2019_xxxx处,参考如下博客:
https://blog.csdn.net/heroybc/article/details/101097166
2.make过程中出现fatal error: boostdesc_bgm.i: No such file or directory,为文件缺失导致,参考博客:
https://blog.csdn.net/ninwji/article/details/100798014
3.make过程中出现fatal error: features2d/test/test_detectors_regression.impl.hpp: No such fil,头文件问题,对策详见博客:
https://blog.csdn.net/ninwji/article/details/100798014
4.make过程中出现error: ‘ppf_match_3d’ was not declared in this scope template,查遍了github上的issue,结论是,在build下面执行:
make clean
之后再make,就OK了
5.使用SIFT过程中出现:opencv-4.1.2/opencv_contrib/modules/xfeatures2d/src/sift.cpp:1207: error: (-213:The function/feature is not implemented) This algorithm is patented and is excluded in this configuration; Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function ‘create’
哈哈~
是因为安装opencv时候,cmake时候没有设置OPENCV_ENABLE_NONFREE=ON,重新cmake,make,install去吧