OpenCV错误。 SiftDescriptorExtractor未在此范围内声明

时间:2016-03-09 18:43:24

标签: c++ opencv

我正在为图像分类编写此代码

#include<stdio.h>
#include <opencv2/opencv.hpp>
#include<vector>
using namespace std;
using namespace cv;
#include <opencv2/nonfree/features2d.hpp>
int main()
{

    //Step 1 - Obtain the set of bags of features.

    //to store the input file names
    char * filename = new char[100];        
    //to store the current input image
    Mat input;    

    //To store the keypoints that will be extracted by SIFT
    vector<KeyPoint> keypoints;
    //To store the SIFT descriptor of current image
    Mat descriptor;
    //To store all the descriptors that are extracted from all the images.
    Mat featuresUnclustered;
    //The SIFT feature extractor and descriptor
    SiftDescriptorExtractor detector;
   }

我收到以下错误:

 In file included from /home/abhinav/Sem6/MachinePerception/Assignment3/1.cc:13:0:
/usr/include/opencv2/nonfree/features2d.hpp:81:5: error: ‘AlgorithmInfo’ does not name a type
 AlgorithmInfo* info() const;
 ^
In file included from /home/abhinav/Sem6/MachinePerception/Assignment3/1.cc:13:0:
 /usr/include/opencv2/nonfree/features2d.hpp:132:5: error: ‘AlgorithmInfo’   does not name a type
 AlgorithmInfo* info() const;
 ^

我不确定这个算法来自哪里,我不知道如何纠正它。

1 个答案:

答案 0 :(得分:0)

你应该添加

#include "opencv2/features2d/features2d.hpp"

之前

#include <opencv2/nonfree/features2d.hpp>