C++ 中的 OpenCV:"Unknown Type Name"
OpenCV in C++: "Unknown Type Name"
我正在尝试按照找到的 OpenCV 教程进行操作 here。本教程的一部分是创建 SURF 特征检测器。
与教程不同,我的代码在头文件中,像这样:
class Img {
Mat mat;
int minHessian = 400;
SurfFeatureDetector detector(minHessian);
public:
...
}
我遇到的错误发生在行
SurfFeatureDetector detector(minHessian);
错误是:
Unknown type name 'minHessian'
当我不把它放在一个单独的 class 中时,编译器不会报错。我也检查过并导入了所需的库。
谁能告诉我错误是什么以及如何解决?
我看了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);
....
ans 据我所知,在这段代码中,SurfFeatureDetector detector(minHessian);
不是函数的签名,您可以像往常一样在头文件中编写它;但它实际上是在代码中调用 SurfFeatureDetector
函数。
所以,我想如果你把它从你的头文件代码中删除,然后把它放在你的函数中,你想调用它的地方,它可能会起作用。
我正在尝试按照找到的 OpenCV 教程进行操作 here。本教程的一部分是创建 SURF 特征检测器。
与教程不同,我的代码在头文件中,像这样:
class Img {
Mat mat;
int minHessian = 400;
SurfFeatureDetector detector(minHessian);
public:
...
}
我遇到的错误发生在行
SurfFeatureDetector detector(minHessian);
错误是:
Unknown type name 'minHessian'
当我不把它放在一个单独的 class 中时,编译器不会报错。我也检查过并导入了所需的库。
谁能告诉我错误是什么以及如何解决?
我看了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);
....
ans 据我所知,在这段代码中,SurfFeatureDetector detector(minHessian);
不是函数的签名,您可以像往常一样在头文件中编写它;但它实际上是在代码中调用 SurfFeatureDetector
函数。
所以,我想如果你把它从你的头文件代码中删除,然后把它放在你的函数中,你想调用它的地方,它可能会起作用。