In Opencv, the cv::Mat object is used as a parameter, and the incoming function is a reference method, which will affect the original image
cv::Mat image;
OperateMat(image); // 函数OperateMat,对image操作,image会同步改变。省略了定义
OpreateMat(image.clone()); // 不会改变image。
OperateMat(image); If the image is not of cv::Mat type, it is pass-by-value according to the c++ value transfer principle, and the image operation in OperateMat will not affect the image; while the incoming parameter is a cv::Mat object
. Not the same, at this time in the OperateMat function to operate on the image, it will change the image synchronously . You can use clone() to avoid changing the original image.