Ask Your Question
1

missing cv::Mat::zeros(int ndims, const int* sz, int type)

asked 2012-11-30 04:52:44 -0600

ryhor gravatar image

updated 2012-11-30 09:50:44 -0600

Under Ubuntu 12.04 I have got from linker "undefined reference to `cv::Mat::zeros(int, int const*, int)'"

for 2.3 from repo and for 2.4.3 compiled from source.

And indeed if I go to the lib directory and ask for list of symbols from object files I can see

~/src/OpenCV-2.4.3/build/lib$ nm ./libopencv_core.so | c++filt | grep zeros

000000000015d690 T cv::Mat::zeros(cv::Size_<int>, int)

000000000015d460 T cv::Mat::zeros(int, int, int)

I.e. there is no cv::Mat::zeros(int , const int* , int)

it is same story for cv::Mat::ones(int , const int* , int)

Any suggestion how to get this into lib?

Update

file core.hpp, lines

1766 static MatExpr zeros(int rows, int cols);

1767 static MatExpr zeros(Size size);

1768 static MatExpr zeros(int _ndims, const int* _sizes);

where can I find implementation of last function? I can find first two, but not the last. What is a point to include function declaration in class if there is no implementation for it?

What is a level of support for N dim Mat in the light of line

91 typedef Mat MatND; ?

edit retag flag offensive close merge delete

Comments

file core.hpp, lines

2778 static MatExpr zeros(int rows, int cols);

2779 static MatExpr zeros(Size size);

2780 static MatExpr zeros(int _ndims, const int* _sizes);

where can I find implementation of last function? I can find first two, but not the last. What is a point to include function declaration in class if there is no implementation for it?

ryhor gravatar imageryhor ( 2012-11-30 08:44:32 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-03-04 20:16:58 -0600

salkuma gravatar image

You could refer to Missing Mat::zeros(int ndims, const int* sz, int type) which is exactly the same problem asked and added Mat::zeros() missing function. However, both opencv 2.4 and 2.4.8.2-pre are still not found this function. The strange thing is that opencv master branch in github of which I guess for opencv 3.0 has Mat::zeros(int ndims, const int* sz, int type) implementation, here. Does anybody know about why 2.4.x removed this?

Thank you in advance.

edit flag offensive delete link more
0

answered 2014-03-05 03:04:19 -0600

updated 2014-03-05 04:42:54 -0600

I have no idea why the function static MatExpr zeros(int _ndims, const int* _sizes) is removed from OpenCV 2.4.x (or not?). But if you want to have a ndims Mat initialized by zeros, you can do like that (in OpenCV 2.4.8):

Mat ucMat = Mat::zeros(nrows, ncols, CV_8UC(ndims)); // for unsigned char
Mat intMat = Mat::zeros(nrows, ncols, CV_32SC(ndims)); // for int
Mat fMat = Mat::zeros(nrows, ncols, CV_32FC(ndims)); // for float
Mat dMat = Mat::zeros(nrows, ncols, CV_64FC(ndims)); // for double
edit flag offensive delete link more

Comments

Its good trick! Thank you.

salkuma gravatar imagesalkuma ( 2014-03-05 04:26:08 -0600 )edit

Question Tools

Stats

Asked: 2012-11-30 04:52:44 -0600

Seen: 3,813 times

Last updated: Mar 05 '14