如何在Opencv3.1中使用SURF?

时间:2016-06-03 08:37:22

标签: c++ opencv sift surf

我有Opencv3.1并与opencv_contrib一起安装。 我可以成功构建以下代码。

#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/highgui.hpp"
#define USE_SURF
#define USE_FLANN

using namespace std;
using namespace cv;
using namespace cv::xfeatures2d;

int imagematching(Mat &first, Mat & second)
{


   return 0;
}

这意味着,我的xfeatures2d已成功安装。然后,当我包括

int imagematching(Mat &first, Mat & second)
{
    int max_keypoints = 500;
    Ptr<SURF> detector = SURF::create( max_keypoints );

    return 0;
}

然后我有错误

[100%] Building CXX object FeaturepointsMatching/CMakeFiles/FeaturepointsMatching.dir/featurepoints_matching.cpp.o
/home/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.cpp: In function ‘int imagematching(cv::Mat&, cv::Mat&)’:
/home/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.cpp:14:13: error: wrong number of template arguments (0, should be 1)
     Ptr<SURF> detector = SURF::create( max_keypoints );
             ^
In file included from /usr/local/include/opencv2/core/base.hpp:56:0,
                 from /usr/local/include/opencv2/core.hpp:54,
                 from /usr/local/include/opencv2/opencv.hpp:48,
                 from /home/nyan/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.h:3,
                 from /home/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.cpp:1:
/usr/local/include/opencv2/core/cvstd.hpp:283:8: error: provided for ‘template<class T> struct cv::Ptr’
 struct Ptr
        ^
/home/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.cpp:14:24: error: invalid type in declaration before ‘=’ token
     Ptr<SURF> detector = SURF::create( max_keypoints );
                        ^
/home/Softwares/3D_images/Reconstruction/FeaturepointsMatching/featurepoints_matching.cpp:14:30: error: ‘::create’ has not been declared
     Ptr<SURF> detector = SURF::create( max_keypoints );
                              ^
make[2]: *** [FeaturepointsMatching/CMakeFiles/FeaturepointsMatching.dir/featurepoints_matching.cpp.o] Error 1
make[1]: *** [FeaturepointsMatching/CMakeFiles/FeaturepointsMatching.dir/all] Error 2
make: *** [all] Error 2

Opencv3.1中的SURF有什么问题? 感谢

0 个答案:

没有答案