I have made one function in which I am passing a matrix and returning processed matrix, but the data of processed matrix is getting copied into the matrix which I passed, for ex.
output=processMatrix(srcCopy);
then when I show both of these matrix, I get same image in srcCopy and output also, I am allocating them memory as;
output=Mat(image.rows,image.cols,CV_8UC1 );
srcCopy=Mat(image.rows,image.cols,CV_8UC1 );
The problem is that the
cv::Matcopy constructor does a shallow copy of the sourcecv::Mat. See here. What you probably need to do is use thecv::MAt::clone()method to create a clone of the original. Then, you can avoid the shallow copy in the function parameter list: