Ask Your Question
1

How can I "Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library in function 'create'"?

asked Oct 28 '18

viohh gravatar image

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?

Preview: (hide)

Comments

CMake -DOPENCV_ENABLE_NONFREE:BOOL=ON

LBerger gravatar imageLBerger (Oct 29 '18)edit

Thank you, but where should I make it? In xfeatures2d?

viohh gravatar imageviohh (Oct 29 '18)edit

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

LBerger gravatar imageLBerger (Oct 29 '18)edit

I built opencv and opencv_contrib, but which cmake file I need?

viohh gravatar imageviohh (Oct 29 '18)edit

if you built opencv and and opencv_contrib do it again :

CMake -DOPENCV_ENABLE_NONFREE:BOOL=ON -DOPENCV_EXTRA_MODULES_PATH=.your_path/opencv_contrib/modules
LBerger gravatar imageLBerger (Oct 29 '18)edit

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 gravatar imagecarnar (Nov 14 '18)edit

@carnar delete cmakecache.txt and rebuild opencv with OPENCV_ENABLE_NONFREE:BOOL=ON

LBerger gravatar imageLBerger (Nov 14 '18)edit

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

carnar gravatar imagecarnar (Nov 14 '18)edit

I've noted that surf.cpp include

#include "precomp.hpp" and #include "surf.hpp". Both are only in the directory  'opencv_contrib-3.4.3\modules\xfeatures2d\src'.

Moreover 'precomp.hpp' include opencv_modules,hpp which has the following lines:

// This definition means that OpenCV is built with enabled non-free code.
// For example, patented algorithms for non-profit/non-commercial use only.
/* #undef OPENCV_ENABLE_NONFREE  */

Should I change anything here to define OPENCV_ENABLE_NONFREE = 1?

carnar gravatar imagecarnar (Nov 14 '18)edit

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 :

    Unavailable:                 java js python2 python3
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         YES

  Windows RT support:            NO
LBerger gravatar imageLBerger (Nov 14 '18)edit

1 answer

Sort by » oldest newest most voted
-1

answered Nov 7 '19

stiv-yakovenko gravatar image

To use SIFT you have to downgrade to 3.4.2.16: more details here

Preview: (hide)

Comments

1

Bad answer and bad idea.

LBerger gravatar imageLBerger (Nov 8 '19)edit

you don't "have to" downgrade, but its certainly a more pain free way then running cmake 100k times, until you guess parameters correctly, pray to the correct gods, trash more monitors and keyboards then is worth it and have all your luck amulets aligned in the pattern required..

why gravatar imagewhy (Mar 11 '0)edit

About sift and surf be patient...

LBerger gravatar imageLBerger (Mar 11 '0)edit

Question Tools

1 follower

Stats

Asked: Oct 28 '18

Seen: 43,897 times

Last updated: Nov 07 '19