Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Need explanation for the following! thanks in advance.

I have the following block of code in main function in C++. I am using openCV 4.1.1.

int a[ ] = { 1,2,3,4,5,6,7,8,9 };

Mat matrix(1, 9, CV_8SC1, &a);

cout<< matrix<<endl;< p="">

The expected output is:

[1, 2, 3, 4, 5, 6, 7, 8, 9]

But the actual output is:

[ 1, 0, 0, 0, 2, 0, 0, 0, 3]

I am able to get the desired output by using the following statement!

Mat matrix(1, 9, CV_32SC1, &a);

Can someone please provide explanation for why CV_8SC1 is not giving the desired output, also provide references if possible. Thanks in advance.