Opencv 3.0 features2d.hpp错误:未知的AlgorithmInfo

Opencv 3.0 features2d.hpp error : unknown AlgorithmInfo

本文关键字:未知 AlgorithmInfo 错误 hpp features2d Opencv      更新时间:2023-10-16

我正在使用opencv3.0开发一个项目,该项目在opencv_contrib github中有额外的模块。我使用的是Xcode 7.0,Yosemite 10.10。我已经在Xcode 中完成了设置

标题搜索路径:/用户/kimloonghew/Documents/opencv/opencv-3.0.0/build/include/usr/local/Cellar/libiomp/20150401/include/libiomp/omp.h/usr/local/include

库搜索路径:/用户/kimloonghew/Documents/occv/opencv-3.0.0/build/lib/usr/local/lib

其他链接器标志:-lopencv_calib3d-lopencv_core-lopenc_features2d-lopencv_frann-lopenv_higgui-lopenc v_imgcodecs-lopency v_imgproc-lopench v_ml-lopencov_objectdetect-loperc v_photo-lopecci v_shape-lopecc v_setting-lopecf v_superes-lopecn v_ts-loppencv_video-lopcv_videostab-lopercv_nofree-lopecl v_vxfeatures2d

这里的代码如下:

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <dirent.h>
#include <string>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <opencv2/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/nonfree/nonfree.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/ml/ml.hpp>
using namespace std;
using namespace cv;
int main(int argc, const char * argv[]) {
    int minHessin = 400;
    string dir = "/Users/DYKLhew/Documents/Food_proj/MIT/foodcamimages/TRAIN", filepath;
    DIR *dp;
    struct dirent *dirp;
    struct stat filestat;
    dp = opendir(dir.c_str());
    SurfFeatureDetector detector(minHessin);
    //Ptr<xfeatures2d::SURF> detector = xfeatures2d::SURF::create(minHessin);
    vector<KeyPoint> keypoints, keypoints_scene;
    Mat descriptors_object, descriptor_scene;
    Mat img;
    cout << "------- build vocabulary ---------n";
    cout << "extract descriptors.."<<endl;
    int count = 0;
    while (count++ < 15 && (dirp = readdir(dp))) {
        filepath = dir + "/" + dirp->d_name;
        if(stat( filepath.c_str(), &filestat )) continue;
        if(S_ISDIR(filestat.st_mode))           continue;
        img = imread(filepath);
        detector.detect(img, keypoints);

        cout << ".";
    }
    cout << endl;
    closedir(dp);
    cout << "Total descriptors : " << count << endl;
    //BOWKMeansTrainer bowtrainer(150);

    return 0;
}

当我运行该文件时,它BUILD失败,在featuares2d.hpp文件中检测到错误。错误如下1( 未知类型名称"AlgorithmInfo";你是说"算法"吗?2( 没有名为"vector"的模板;你是说"std::vector"吗

我在设置或安装opencv时做错了什么?或者我必须定义的任何链接路径?非常感谢你的建议。感谢

解决的问题:

Xcode编译器是智能的,它能够预测与您当前机器配置匹配的解决方案。如果您只是遵循Xcode编译器给出的建议,问题就解决了。

系统无法识别AlgorigthmInfo,您可以将其更改为Algorigthm,也可以将vector更改为std::vector

现在在我的机器中openCV完全工作良好。

希望,如果面临同样的问题,这将帮助其他一些人。