环境:ubuntu18.04,opencv-contribute和opencv(注意版本一致)已经装好,win11
一、在用SIFT算法的时候,出现了报错:
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'
二、原因是pencv_contrib提供了一些有专利的函数。
三、解决办法:
在opencv的目录下mkdir build,再cd build
cmake -D OPENCV_ENABLE_NONFREE:BOOL=ON -D INSTALL_C_EXAMPLES=ON OPENCV_EXTRA_MOUDLES_PATH=绝对路径/opencv_contrib-3.4.16/modules ..
make
sudo make install
-D OPENCV_ENABLE_NONFREE:BOOL=ON 语句可以生成SURF等有专利的算法的库,有了这些库就可以使用SURF等算法
。
至此,问题解决。