0

I have a strange error using opencv under visual studio 11. When I do this:

int sz[]={3,3,3};
T=Mat(3,sz,CV_32F);

or this (2D matrix initialized to ones):

T=Mat::ones(3,3,CV_32F);

everything works fine

but this (3D matrix initialized to ones):

int sz[]={3,3,3};
T=Mat::ones(3,sz,CV_32F);

gives me a linking error:

Error 6 error LNK2019: unresolved external symbol "public: static class cv::MatExpr __cdecl cv::Mat::ones(int,int const *,int)"

Why is this? Do I need to link something extra when I initialize n dimensional matrices with ones?

Cœur
  • 37,241
  • 25
  • 195
  • 267
paghdv
  • 554
  • 1
  • 4
  • 14

1 Answers1

2

As far as I know the ones method create only 2D matrix, if you want to initialize your matrix with a specified values you have to do it with the constructor

int sz[]={3,3,3};
T=Mat(3,sz,CV_32F, Scalar::all(1));
  • I can also infer this from the error but why the linking error? Is it maybe a method from another class? (I don't think so). I also see no reason why is this only implemented for 2D matrices. – paghdv Jun 27 '13 at 14:14
  • It seems like the method cv::Mat::ones(int,int const *,int) for multidimensional matrix has been declared in the header files but it has no implementation, from this the linker error – Andrea Riccardi Jun 28 '13 at 06:31