Feature matching tutorial compilation problem
I am trying to compile the code in this tutorial, but I get the following error messages:
feature.cpp: In function ‘int main(int, char**)’:
feature.cpp:26:3: error: ‘SurfFeatureDetector’ was not declared in this scope
feature.cpp:26:23: error: expected ‘;’ before ‘detector’
feature.cpp:30:3: error: ‘detector’ was not declared in this scope
feature.cpp:34:3: error: ‘SurfDescriptorExtractor’ was not declared in this scope
feature.cpp:34:27: error: expected ‘;’ before ‘extractor’
feature.cpp:38:3: error: ‘extractor’ was not declared in this scope
feature.cpp:24:7: warning: unused variable ‘minHessian’ [-Wunused-variable]
However, I am pretty sure I linked the right libraries. Here is my build command (from Geany):
g++ -Wall -o "%e" "%f" -I /usr/include/opencv2/ -lopencv_features2d -lopencv_core -lopencv_highgui -lopencv_imgproc
I don't understand why it doesn't work because the core and highgui libraries are not causing any issue. I checked my /usr/include/opencv2/features2d folder and I did find features2d.hpp. However, if I replace
#include "opencv2/features2d/features2d.hpp"
in the program by
#include "opencv2/nonfree/features2d.hpp"
I get the following compilation error:
/usr/bin/ld: /tmp/ccVyvyXB.o: undefined reference to symbol 'cv::flann::SearchParams::SearchParams(int, float, bool)'
/usr/bin/ld: note: 'cv::flann::SearchParams::SearchParams(int, float, bool)' is defined in DSO /usr/lib/libopencv_flann.so.2.3 so try adding it to the linker command line
/usr/lib/libopencv_flann.so.2.3: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
What am I doing wrong? Thanks!