I need to copy my image data from one Mat another Mat. My code look like below
Mat src; // Source image
Mat res(1024,768,CV_8UC3); //Same width and height as source
uchar *dest=src.data;
res.data=dest;
But I am getting distorted destination image. Is it my coding problem?
Thanks in advance!
If width and height is the same than it seems that problem is with number of channels (number of bytes per pixel). Try to change
CV_8UC3toCV_8UC1.And also your code doesn’t copy data, it copies pointers. Read documentation about
memcpy.Actually you should use method
cloneofcv::Mat: