我使用的是 visual studio professional 2013。我使用的是 opencv。而且我已经正确链接了所有 opencv 库。
- 程序在 main.cpp 中运行(我已经测试了很多 opencv 程序)
- 在类中使用的相同程序,给出未定义的错误(即使是简单的 mat 对象也无法在给出未定义错误的类中创建。)
我该如何解决这个问题?
请在下面找到我使用的代码(这个未定义的 Mat 问题不会出现在 main.cpp 中)
#pragma once
#include "stdafx.h"
#include <opencv2/highgui/highgui.hpp> // import no include errors
#include <opencv2/imgproc/imgproc.hpp> // import no include errors
#include <opencv2/core/core.hpp> // import no include errors
class DepthImage
{
public:
DepthImage();
~DepthImage();
private:
Mat image; //identifier "Mat" is undefined
};
最佳答案
#pragma once
//#include "stdafx.h" never in header file
#include <opencv2/highgui/highgui.hpp> // import no include errors
#include <opencv2/imgproc/imgproc.hpp> // import no include errors
#include <opencv2/core/core.hpp> // import no include errors
class DepthImage
{
public:
DepthImage();
~DepthImage();
private:
cv::Mat image; //no more identifier "Mat" is undefined
};
希望对你有帮助
关于c++ - opencv 标识符 "Mat"在头文件中使用时未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41372668/