在Mac OS 上安装OpenCV4.5.1时没有SIFT和SURF算法的处理方法

在Mac OS 上安装OpenCV4.5.1时,下载的是源代码,进行本地编译和安装。安装好了之后,使用以前写的image stitching的代码进行测试,本以为会风平浪静,没想到弹出错误:

xfeatures2d/src/surf.cpp:1029: 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_contrib了呀,上网查询,才发现:This section describes two popular algorithms for 2d feature detection, SIFT and SURF, that are known to be patented. You need to set the OPENCV_ENABLE_NONFREE option in cmake to use those. Use them at your own risk.

看到了没有,有专利,你可以使用,但是呢你得自己负责,在编译的时候使用OPENCV_ENABLE_NONFREE 这个选项。好了自己重新编译吧:cmake -DCMAKE_INSTALL_PREFIX=/usr/local/OpenCV4.5 -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-master/modules -DCMAKE_BUILD_TYPE=RELEASE -DOPENCV_ENABLE_NONFREE=ON ..

我的4核CPU编译起来也不快呀!

等了接近20分钟,终于好了,告诉小伙伴,我在CMake过程中,下载文件顺利。再测试,OK啦!!!

 

你可能感兴趣的:(计算机视觉,opencv,cmake,c++)