1 | initial version |
on a 32bit system an int takes the same space as 4 bytes. so, if you set the type of the Mat header to CV_8S, it only considers the first 9 bytes in memory.
char a[ ] = { 1,2,3,4,5,6,7,8,9 };
Mat matrix(1, 9, CV_8SC1, &a);
(char array instead of int) would have been, what you wanted there.
in the end, you have to be very careful, using a Mat constructor with external data like above. apart from the type problem, this type of Mat is NOT refcounted, and once your initial data goes out of scope, your Mat is invalid ("dangling pointer")