Incomplete type "cv::Mat" opencv c++
Asked Answered
S

2

6

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?

Sheffield answered 9/1, 2014 at 21:23 Comment(7)
You should only include core.hpp, but is sounds like a linker errorTellus
I found a response on stackoverflow on how to link opencv with xcode, so I followed all the step. So does this linker error is something about xcode itself?Sheffield
This looks more like a compiler error to me, not a linker output.Kwarteng
how do xcode and window.h go together ? sounds you made some general mess of it ..Houseraising
start with readjusting your include path, so it points to opencv/build/include. try with only: #include "opencv2/core/core.hpp" , skip all other headers (especially the windows.h one).Houseraising
also, why do you need opencv for a raytracer ? seems like total abuse. it's a computer-vision/machine-learning lib after all ! if all you need is to blit an image, use sdl / opengl / cairo / whatever_your_os_offers_nativelyHouseraising
I wanted to create the image with opencv. I asked a friend what could I use to make an image/matrix in c++ and he said me opencvSheffield
C
5

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();
}
Chanellechaney answered 17/8, 2015 at 9:33 Comment(0)
T
0

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?

Tellus answered 9/1, 2014 at 22:56 Comment(1)
I just included core/core.hpp and I had also to include type.hpp because CV_8UC3 is not in core.hpp and I still have this problem. :(Sheffield

© 2022 - 2024 — McMap. All rights reserved.