c++ - opencv 标识符 "Mat"在头文件中使用时未定义

标签 c++ opencv visual-studio-2013

我使用的是 visual studio professional 2013。我使用的是 opencv。而且我已经正确链接了所有 opencv 库。

  1. 程序在 main.cpp 中运行(我已经测试了很多 opencv 程序)
  2. 在类中使用的相同程序,给出未定义的错误(即使是简单的 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/

相关文章:

python - 检测不规则图像中的形状

apache-spark - 使用 Apache Spark 和 OpenCV 进行图像分析

c++ - Visual Studio 中 MIDL 编译器的默认路径是什么?

c++ - 如何重载cin来读取文件

c++ - stringstream 不适用于 OSX 10.6 上的 Rcpp

c++ - 使用带有默认构造函数的 sf::Shape

c++ - 如何获得编译警告

python - 图像中的对象(简单形状)检测

WPF XAML 定义的 MenuItem 重用开始工作,然后消失

javascript - 无法使用 angularjs ng-src 访问我的设备本地存储中的图像文件