From the OpenCV documentation, it appears that copying a matrix is done using a shallow copy, but when changing one of the copies, a copy is done.
The exact referenc
You can make a deep copy with Mat::copyTo(). E.g.
Mat::copyTo()
Mat a(5,5,CV_32C1),b; a = 1; a.copyTo(b); a = 2;
But no, Mat does not support copy-on-write. When you need to make a change to a without affecting b, you need to make a deep copy of a to b, and then modify a.
Mat
a
b