Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CvMat zero initialization confusion with cv::Mat

I was reading a code which was like this :

CvMat * MyMat[10];

for(int i = 0; i<10; i++)
{
    MyMat[i] = 0;
}

what does this do ?

Does it initialize the MyMat to 0.

And if I want to do the same in cv::Mat , can I do

cv::Mat MyMat[10];

for(int i = 0; i<10; i++)
{
    MyMat.setTo(Scalar::all(0));
}

CvMat zero initialization confusion with cv::Mat

I was reading a code which was like this :

CvMat * MyMat[10];

for(int i = 0; i<10; i++)
{
    MyMat[i] = 0;
}

what does this do ?

Does it initialize the MyMat to 0.

And if I want to do the same in cv::Mat , can I do

cv::Mat MyMat[10];

for(int i = 0; i<10; i++)
{
    MyMat.setTo(Scalar::all(0));
MyMat[i].setTo(Scalar::all(0));
}