簡體   English   中英

C ++中的OpenCV:“未知類型名稱”

[英]OpenCV in C++: “Unknown Type Name”

我正在嘗試遵循OpenCV教程(在此處找到)。 本教程的一部分是創建SURF特征檢測器。

與本教程不同,我的代碼位於頭文件中,如下所示:

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

    public:
        ...
}

我得到的錯誤在線上發生

SurfFeatureDetector detector(minHessian);

錯誤是:

Unknown type name 'minHessian'

當我不將其放在單獨的類中時,編譯器不會抱怨。 我還檢查了並導入了所需的庫。

誰能告訴我錯誤是什么以及如何解決?

我閱讀了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函數。
因此,我認為如果將其從頭文件代碼中刪除,然后將其放在要調用它的函數中,則它可能會起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM