Regarding setting flags while building opencv c++

So whenever we build opencv from source we end up setting the flag
OPENCV_ENABLE_NONFREE=ON.
Not doing this results in the dreaded error “xfeatures2d.hpp not found” or something similar to that.
So my question how does setting this particular flag.I mean once this flag is set the cmake build works fine and you end up with the perfect opencv build.
It’s just a random thought that popped in my mind at 1AM .

Platform?
how do you download opencv and opencv_contrib?
What is you cmake command?
Can you give full error message?

Platform ubuntu 16.04 OS
Error that I used to get

matching2D.hpp:16:35: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
 #include <opencv2/xfeatures2d.hpp>

The error was resolved by using the following instructions
1.

git clone https://github.com/opencv/opencv.git
cd opencv
git checkout 4.1.0
cd .. #get out of opencv folder

2.Get opencv-contrib

https://github.com/opencv/opencv_contrib/
cd opencv_contrib
git checkout 4.1.0
cd .. #get out of opencv_contrib folder

3.Install

cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules -D WITH_GTK=ON ..
make
sudo make install

As such how exactly does setting the flag opencv_enable_nonfree help in resolving this error?

Why do you use opencv 4.1.0?

delete content of buid repo (all files)

1 Like

any issue must be replicable with most recent release.

if you insist on using an obsolete version, and you get issues that have already been fixed in a newer version, you’re on your own.

This topic was automatically closed after 7 days. New replies are no longer allowed.