In my application, I want to create a OpenCV Mat A (2-Dimensions) having some values and then pass it to another OpenCV function using A as input.
Currently, I’m trying:
// float data[2][5] = {{1,2,3,4,5},{7,8,9,10,11}};
// OR
float data[10] = {1,2,3,4,5,7,8,9,10,11};
// and then
// A = Mat(1, 5, CV_32FC1, &data, 2); // init from float 1D - array
// OR
A = Mat(2, 5, CV_32FC1, &data, 2);
in case of 1D array, the value passing is OK. But this does not work for 2D array, which is even more a common case. How can I solve this in OpenCV??
Originally, I used the mnemonic from OpenCV online guides:
But I didn’t understand what the document meant by
size_t step=AUTO_STEP. And this means that I can omit thestepargument with which OpenCV will automatically chooseAUTO_STEPI’ve tried and this works:
for the 2D Mat initialized from array