1
votes

I have a two dimension double type matrix.

double ** results; (8334*34 size)

The values are something like: 0.00211094, 0, 6.10098e-006.......

I use the code Mat m = Mat(ROW, COL, CV_64F, results),

but when I check the element, I found the values are not match, and the value in m in very strange, something like 5.325e-344 (too small!)

cout<(0,0) != result[0][0]

I test a small matrix, and the answer match the matrix.

double a = 0.00211094;
double b = 6.10098e-006;
double c=0;
double aa[3][3] = {{a, b, c}, {0.4, 0.5, 0.6}, {0.7, 0.8, 0.9}};
Mat m = Mat(3, 3, CV_64F, aa);

cout<<m.at<double>(0,1)<<endl;

Could anyone tell me why? Is this my C++ memory's problem (results matrix is too large?)?

1
Is it possible that the Mat was non-contiguous and you were accessing the padding sections of the memory? - alrikai

1 Answers

0
votes

only small matrix could be set into Mat.

So I try to set each element into mat.

for(i...){
for(j...){
    m.at<double>(i,j) =results[i][j];
}
}

and it works.

Interesting!