Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

print comparison matrix elements

I want to know why trying to access (and print) test matrix results in showing garbage:

Mat A = (Mat_<double>(3,3) << 0, -1.4, 0.2, -1, 5.4, -1, 0.1, -1.4, 0);
cout << "A = " << endl << " " << A << endl << endl;

Mat B = (Mat_<double>(3,3) << 0, -1.4, 0.4, -2, 5.4, -11, 0, -1.42, 0);
cout << "B = " << endl << " " << B << endl << endl;

Mat test = Mat(3,3,CV_64F);

test = ( A == B ); 

for ( int i = 0; i < 3; i++ )     
{         
    for (int j = 0; j < 2; j++ )         
    {             
        cout << test.at<int>(i,j) << endl;
    }             
}

If I use just cout << test it is ok ,but I want to know why the previous doesn't work.

Thanks!