【问题标题】:OpenCV in C++: "Unknown Type Name"C++ 中的 OpenCV:“未知类型名称”
【发布时间】:2015-09-28 03:05:59
【问题描述】:

我正在尝试遵循 OpenCV 教程,发现 here。本教程的一部分是创建一个 SURF 特征检测器。

与教程不同,我的代码在头文件中,如下所示:

class Img {
    Mat mat;
    int minHessian = 400;
    SurfFeatureDetector detector(minHessian);

    public:
        ...
}

我得到的错误发生在线路上

SurfFeatureDetector detector(minHessian);

错误是:

Unknown type name 'minHessian'

当我不把它放在一个单独的类中时,编译器不会抱怨。我也检查过并导入了所需的库。

谁能告诉我错误是什么,以及如何解决它?

【问题讨论】:

    标签: c++ opencv xcode6


    【解决方案1】:

    我看了opencv教程代码:

    Mat img1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
    Mat img2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
    if(img1.empty() || img2.empty())
    {
        printf("Can't read one of the images\n");
        return -1;
    }
    
    // detecting keypoints
    SurfFeatureDetector detector(400);
    vector<KeyPoint> keypoints1, keypoints2;
    detector.detect(img1, keypoints1);
    detector.detect(img2, keypoints2);
    ....
    

    据我了解,在此代码中,SurfFeatureDetector detector(minHessian); 不是您可以像以前那样在头文件中编写的函数的签名;但它实际上是在代码中调用SurfFeatureDetector 函数。
    所以,我认为如果你从你的头文件代码中删除它,并将它放在你想要调用它的函数中,它可能会起作用。

    【讨论】:

      猜你喜欢
      • 2018-10-27
      • 1970-01-01
      • 2013-09-25
      • 2012-02-06
      • 1970-01-01
      • 1970-01-01
      • 2021-07-21
      • 2013-04-26
      相关资源
      最近更新 更多