Incomplete type "cv::Mat" opencv c++

4.9k Views Asked by At

I want to create a matrice in opencv for my project of raytracing. This is the code I have come up:

#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;
}

And I have problem with the two Mat. It says variable has incomplete type "cv::Mat". I can't understand what it means. I always wrote only Mat nothing else.

Can someone help me please?

2

There are 2 best solutions below

1
On

You only need to '#include "core/core.hpp"`

The compiler needs to be able to find the include files, do you have Opencv/Include in the compiler's include directory list? Did it give any error about finding core.hpp?

0
On

Just include "opencv2/core/core.hpp".
You can use below example code.

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

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

int main()
{
   createImage();
}