不完整类型“cv::Mat”opencv c++

Eki*_*ica 6 c++ opencv incomplete-type mat

我想在 opencv 中为我的光线跟踪项目创建一个矩阵。这是我想出的代码:

#include "Windows.h"
#include "core/mat.hpp"
#include "core/core.hpp"
#include "core/types_c.h"

using namespace cv;

Mat createImage()
{
     Mat b(480, 640, CV_8UC3);
     return b;
}
Run Code Online (Sandbox Code Playgroud)

我对两个垫子有疑问。它说variable has incomplete type "cv::Mat"。我不明白这意味着什么。我总是只写Mat,不写其他东西。

有人能帮助我吗?

Sag*_*tel 5

只需包含“opencv2/core/core.hpp”即可。
您可以使用下面的示例代码。

#include "opencv2/core/core.hpp"
using namespace cv;   

Mat createImage()
{
 Mat b(480, 640, CV_8UC3);
 return b;
}

int main()
{
   createImage();
}
Run Code Online (Sandbox Code Playgroud)


Mar*_*ett 0

你只需要'#include "core/core.hpp"`

编译器需要能够找到包含文件,Opencv/Include编译器的包含目录列表中有吗?查找 core.hpp 时是否出现任何错误?