initialize an OpenCV Mat with an 2D array

Originally, I used the mnemonic from OpenCV online guides:

Mat::Mat(Size size, int type, void* data, size_t step=AUTO_STEP)

But I didn’t understand what the document meant by size_t step=AUTO_STEP. And this means that I can omit the step argument with which OpenCV will automatically choose AUTO_STEP

I’ve tried and this works:

A = Mat(2, 5, CV_32FC1, &data);

for the 2D Mat initialized from array

Leave a Comment