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?

themarex
  • 909
  • 7
  • 16
Ekica
  • 73
  • 1
  • 8
  • You should only include core.hpp, but is sounds like a linker error – Martin Beckett Jan 09 '14 at 21:39
  • 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? – Ekica Jan 09 '14 at 22:22
  • This looks more like a compiler error to me, not a linker output. – AlexK Jan 09 '14 at 22:31
  • how do xcode and window.h go together ? sounds you made some general mess of it .. – berak Jan 09 '14 at 22:57
  • 1
    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). – berak Jan 09 '14 at 23:00
  • 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_natively – berak Jan 09 '14 at 23:37
  • 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 opencv – Ekica Jan 12 '14 at 17:06

2 Answers2

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();
}
Sagar Patel
  • 864
  • 1
  • 11
  • 22
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?

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • 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. :( – Ekica Jan 10 '14 at 12:31