opencv 标识符“Mat”在头文件中使用时未定义

Ala*_*lan 2 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  
};
Run Code Online (Sandbox Code Playgroud)

Ang*_*ica 6

#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  
};
Run Code Online (Sandbox Code Playgroud)

希望能帮到你