打开CV错误.SiftDescriptorExtractor 未在此范围内声明

OpenCV Error. SiftDescriptorExtractor not declared in this scope

本文关键字:范围内 声明 CV 错误 SiftDescriptorExtractor 打开      更新时间:2023-10-16

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

#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;
 ^

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

你应该添加

#include "opencv2/features2d/features2d.hpp"

以前

#include <opencv2/nonfree/features2d.hpp>