【发布时间】:2017-05-13 08:43:35
【问题描述】:
我正在使用 Visual Studio Professional 2013。在那里我使用了 opencv。而且我已经正确链接了所有opencv库。
- 程序在 main.cpp 中运行(我测试了很多 opencv 程序)
- 在类中使用相同的程序,产生未定义的错误(即使是简单的 mat 对象也无法在产生未定义错误的类中创建。)
我该如何解决这个问题?
请在下面找到我使用的代码(main.cpp 中不会出现这个未定义的 Mat 问题)
#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
};
【问题讨论】:
-
不要在标题中包含
stdafx.h。stdafx.h应该是每个 cpp 文件中的第一个包含,但从不包含在标头中。 -
@drescherjm 我试过了,但我遇到了同样的问题。请在下面找到s23.postimg.org/ne23bgcaj/Capture.png
-
尝试 cv::Mat 数据;
-
同意,您忘记了 cv 命名空间。
-
@Angelica 谢谢我忘记了命名空间。谢谢。
标签: c++ opencv visual-studio-2013