0
votes

I'm trying to follow along with the OpenCV tutorial, found here. Part of the tutorial is to create a SURF feature detector.

Unlike the tutorial, my code is in a header file, like this:

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

    public:
        ...
}

The error I'm getting occurs on the line

SurfFeatureDetector detector(minHessian);

and the error is:

Unknown type name 'minHessian'

When I do not put this in a separate class, the compiler does not complain. I have also checked and I have imported the required libraries.

Can anybody tell me what the error is, and how to fix it?

1

1 Answers

1
votes

I read the opencv tutorial code:

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);
....

ans as I understand, in this code, the SurfFeatureDetector detector(minHessian); is not a signature of a function that you can write in your header file as you did; but it's actually calling the SurfFeatureDetector function in the code.
So, I think if you remove it from your header file code, and put it in your function(s), where you want call it, it may work.