When trying to compile a feature detection algorithm I get the following compile error:
I’m compiling/linking with clang, and my OpenCV version is the 2.3.1 release. I’m following (roughly) this tutorial to get the feature matching: http://opencv.itseez.com/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html
error: use of undeclared identifier 'SurfDescriptorExtractor';
did you mean 'OrbDescriptorExtractor'?
SurfDescriptorExtractor extractor;
^
Interestingly Brief and Orb descriptor extractors work “fine”(I end up getting a runtime error).
Here is the relevant code:
void setup_and_draw_keypoints(Mat& img, Mat& prev)
{
// Detect Keypoints
vector<KeyPoint> keypoints, prev_keypoints;
GoodFeaturesToTrackDetector gftt;
gftt.detect(img, keypoints);
gftt.detect(prev, prev_keypoints);
//Extract Descriptors
SurfDescriptorExtractor extractor;
Mat desc_1, desc_2; // Descriptors
extractor.compute(img, keypoints, desc_1);
extractor.compute(prev, prev_keypoints, desc_2);
FlannBasedMatcher matcher;
vector<DMatch> matches;
matcher.match(desc_1, desc_2, matches);
}
The fact that something is in the documentation of your library does not necessarily mean it is in the .so and headers of your library 😉
Open CV has multiple modules, and one of them is flann, which probably only gets compiled when flann is installed and you might even need to explicitly ask for it. when you run cmake or cmake-gui on a source tar.gz download of opencv, you get to select which modules to compile.
Maybe you did not compile opencv from source, in this case your linux system package maintainer did, and might not have included it.
This is how you might find out:
As you can see, I am as lucky to have flann installed 😉