How can I "Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'"?
I built opencv_contrib and some of the modules are working, however when I'm trying to use SURF I get: "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'". So how can I enable nonfree?
CMake -DOPENCV_ENABLE_NONFREE:BOOL=ON
Thank you, but where should I make it? In xfeatures2d?
You have to build opencv and opencv_contrib (git cloneyourself). it is recommended to use them alongside the master branch or latest releases of OpenCV.
Then you can setOPENCV_ENABLE_NONFREE in cmake-gui or in cmake command line
I built opencv and opencv_contrib, but which cmake file I need?
if you built opencv and and opencv_contrib do it again :
I 'm having the same problem.
I built opencv and opencv_contrib 3.4.3 and I set OPENCV_ENABLE_NONFREE in cmake-gui ON and I checked that the Non-free algorithms were installed.
In the test code of surf, at the following line:
detector = SURF::create(minHessian);
it enters in this parte of code (inside surf.cpp)
else // ! #ifdef OPENCV_ENABLE_NONFREE
Ptr<surf> SURF::create(double, int, int, bool, bool) { CV_Error(Error::StsNotImplemented, "This algorithm is patented and is excluded in this configuration; " "Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library"); }
endif
What can I do to enable #ifdef OPENCV_ENABLE_NONFREE?
Thanks for any help
@carnar delete cmakecache.txt and rebuild opencv with OPENCV_ENABLE_NONFREE:BOOL=ON
I made it, but still it doesn't work.
Here what I have in the cmakecache.txt...I think is correct...
//Enable non-free algorithms OPENCV_ENABLE_NONFREE:BOOL=ON
//Where to look for additional OpenCV modules (can be ;-separated // list of paths) OPENCV_EXTRA_MODULES_PATH:PATH=C:/Codice/OpenCV/opencv_contrib-3.4.3/modules
I've noted that surf.cpp include
Moreover 'precomp.hpp' include opencv_modules,hpp which has the following lines:
Should I change anything here to define OPENCV_ENABLE_NONFREE = 1?
No don't change source code. again delete cmakecache an run cmakegui and set OPENCV_ENABLE_NONFEE and after generate you will see in cmake output :