Initialize Mat with color data
Hello, I'm trying to initialize a Mat with BGR data. I'm getting a strange results.
I do this all the time: Mat image(Size(cols, rows), CV_8UC1, (void*) inputData, Mat::AUTO_STEP);
But when I do it with a color image the output mat is not correct (its offset in all of BGR data, vertical and horizontal dimensions).
Even if I trim the code to:
Mat image2 = Mat(Size(imageIn.cols, imageIn.rows), imageIn.type(), imageIn.data, Mat::AUTO_STEP);
image2 is not imageIn.
imageIn.type() is CV_8UC3.
What am I doing wrong?
Thanks for your help,
Gunter
Hi,i think you should chek the size of your source image ,especially column number,It should be quadruple to show image.for example.your source image size is 21x21,you should declare new image size 21x24.Then you fill data one pixel by one pixel. The other is seted to zero,