Ubuntu16下opencv3 +opencv_contrib3最简单安装,并解决SIFT 和 SURF在opencv3以上应用报错

opencv下载Releases - OpenCV,可选择source或者github

直接下载对应的版本,利用cmake编译后,SIFT 和 SURF仍不可用 (OPENCV_ENABLE_NONFREE)

SIFT 和 SURF在opencv3以上应用报错!!!

在opencv3以上用SIFT 和 SURF,需要编译opencv_contrib3.(版本对应),直接按照opencv_contrib3.上的readme安装,发现SIFT 和 SURF仍不可用,报错如下:

"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'"

解决方法:重新安装步骤:

1.重新在opencv的build文件中cmake,指令如下:

cmake  -D OPENCV_ENABLE_NONFREE:BOOL=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv-3.4.3/opencv_contrib-3.4.3/modules ..

其中:1)OPENCV_ENABLE_NONFREE:BOOL=ON 必须指定,本人一开始安装直接按照opencv_contrib的readme安装,发现无法使用,原因就是该语句没有打开。

2)指定opencv_contrib下modules的路径,换成你的路径,OPENCV_EXTRA_MODULES_PATH=~/opencv-3.4.3/opencv_contrib-3.4.3/modules。

2. cmake成功后执行:

sudo make

sudo make install

注意:

1.若make过程总是报#error "C++11 is not supported"的错误,并且连续两遍编译不通过,首先检查指定opencv_contrib下modules的路径是否正确,若正确还报,找到报错的位置下的cmakelists.txt文件,找到

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

类似的CMAKE_CXX_FLAGS ,看那一句没有-std=c++11,加上即可;

2.编译openc_contrib 提示缺少boostdesc_bgm.i文件出错

可以在此下载:

opencv3中的vgg和boost下载-咨询文档类资源-CSDN下载

并将解压的所有文件放入  ../opencv_contrib/modules/xfeatures2d/src/ 中;

3.编译出现opencv-3.4.3/modules/stitching/include/opencv2/stitching/detail/matchers.hpp:52:12: fatal error: opencv2/xfeatures2d/cuda.hpp: No such file or directory

在报错的那个模块,这里是stitching文件夹下的CMakeLists中添加:

INCLUDE_DIRECTORIES("~/opencv-3.4.3/opencv_contrib-3.4.3/modules/xfeatures2d/include") (注意自己的路径)

完成后即可应用。

参考:

1.  https://blog.csdn.net/weixin_45617478/article/details/102632088?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

2.   https://answers.opencv.org/question/201938/how-can-i-set-opencv_enable_nonfree-cmake-option-and-rebuild-the-library-in-function-create/

3.  关于make提示must be enabled with the -std=c++11 or -std=gnu++11 compiler options_StrugglePeach的专栏-CSDN博客

你可能感兴趣的:(opencv,opencv,linux,cmake)