Problem with "SurfFeatureDetector" function

1,082 views
Skip to first unread message

Isaac

unread,
Dec 31, 2012, 10:26:29 AM12/31/12
to opencvde...@googlegroups.com
Hi,
I have few days working with OpenCV, I started with OpenCV 2.1 and I made an object tracker with "cvMatchTemplate" function, but now I've changed to OpenCV 2.4.3 to use the "SurfFeatureDetector" function but I got this error:

main.cpp: In function ‘int main()’:
main.cpp:31:5: error: ‘SurfFeatureDetector’ was not declared in this scope
main.cpp:31:25: error: expected ‘;’ before ‘detector’
main.cpp:34:5: error: ‘detector’ was not declared in this scope
main.cpp:37:5: error: ‘SurfDescriptorExtractor’ was not declared in this scope
main.cpp:37:29: error: expected ‘;’ before ‘extractor’
main.cpp:40:5: error: ‘extractor’ was not declared in this scope


Including the following

#"opencv2/features2d/features2d.hpp"
#"opencv2/highgui/highgui.hpp"
#"opencv2/core/core.hpp"
#"opencv2/legacy/legacy.hpp" (BruteForceMatcher is defined here!)

and linking against the following

#opencv_core.so
#opencv_flann.soo (if youre using the FLANN matcher)
#opencv_highgui.so
#opencv_features2d.so
#opencv_nonfree.so
I understand that in the first part is:

#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/legacy/legacy.hpp"
but in the other part I don't know how to add them. I tried to ask in that foro but I got problem with the subscription. I'll be thankful for any help.

Thanks.

Isaac

unread,
Dec 31, 2012, 12:23:13 PM12/31/12
to opencvde...@googlegroups.com
I just resolved the problem.

I had to add this includes:

#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>

and this line in my code:

int main()
{
initModule_nonfree();//THIS LINE IS IMPORTANT 

        // My Code
}

Problem solved!!


Reply all
Reply to author
Forward
0 new messages