Ask Your Question
1

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

asked 2018-10-28 16:55:33 -0600

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?

edit retag flag offensive close merge delete

Comments

CMake -DOPENCV_ENABLE_NONFREE:BOOL=ON

LBerger gravatar imageLBerger ( 2018-10-29 02:21:25 -0600 )edit

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

viohh gravatar imageviohh ( 2018-10-29 06:43:31 -0600 )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 ( 2018-10-29 06:47:55 -0600 )edit

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

viohh gravatar imageviohh ( 2018-10-29 07:01:47 -0600 )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 ( 2018-10-29 07:51:27 -0600 )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 ( 2018-11-14 08:30:14 -0600 )edit

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

LBerger gravatar imageLBerger ( 2018-11-14 09:06:18 -0600 )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 ( 2018-11-14 09:31:12 -0600 )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 ( 2018-11-14 09:53:38 -0600 )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 ( 2018-11-14 09:57:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
-1

answered 2019-11-07 16:14:21 -0600

stiv-yakovenko gravatar image

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

edit flag offensive delete link more

Comments

1

Bad answer and bad idea.

LBerger gravatar imageLBerger ( 2019-11-07 20:20:05 -0600 )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 ( 2020-03-11 08:16:06 -0600 )edit

About sift and surf be patient...

LBerger gravatar imageLBerger ( 2020-03-11 08:31:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-10-28 16:55:33 -0600

Seen: 43,047 times

Last updated: Nov 07 '19