Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
338 views
in Technique[技术] by (71.8m points)

c++ - OpenCV SURF function is not implemented

When I try to run the sample find_obj.cpp or any OpenCV SURF program I get the following error in command prompt while executing the code. The project builds without errors and warnings. I am using VS2011 beta, OpenCV 2.4 and windows7.

Error message:

OpenCV Error: The function/feature is not implemented < OpenCV was built without SURF support> in unknown function,file ......srcopencvmoduleslegacysrcfeatures2d.cpp, line 77

I tried to build the OpenCV 2.4 again using Cmake and then VS2011 in debug mode and then added the lib paths in the IDE, but still no result.

How can I fix that?

    #include <opencv2/objdetect/objdetect.hpp>
    #include <opencv2/features2d/features2d.hpp>
    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <opencv2/legacy/legacy.hpp>
    #include <opencv2/legacy/compat.hpp>
    #include <opencv2/flann/flann.hpp>
    #include <opencv2/calib3d/calib3d.hpp>
    #include <opencv2/nonfree/features2d.hpp>
    #include <opencv2/nonfree/nonfree.hpp>

using namespace std;
using namespace cv;
int main()
{
    cv::initModule_nonfree();//THIS LINE IS IMPORTANT   

   IplImage *image1 = cvLoadImage("C:\SURF\1.jpg"); 
    IplImage *image2 = cvLoadImage("C:\SURF\2.jpg");

    CvMemStorage* memoryBlock = cvCreateMemStorage();
    CvSeq* image1KeyPoints;
    CvSeq* image1Descriptors;
    CvSeq* image2KeyPoints;
    CvSeq* image2Descriptors;

    // Only values with a hessian greater than 500 are considered for keypoints
   CvSURFParams params = cvSURFParams(500, 1);
   cvExtractSURF(image1, 0, &image1KeyPoints, &image1Descriptors, memoryBlock, params);
   cvExtractSURF(image2, 0, &image2KeyPoints, &image2Descriptors, memoryBlock, params);

   return 0;
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Taken from this answer (why don't you google your question before asking?):

The SIFT and SURF code was moved in OpenCV v2.4 to a new module called nonfree. Make sure you are linking (DLL in Windlows) to it. In linux this library is called libopencv_nonfree.so.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...