copyTo method
Copies the matrix to another one.
The method copies the matrix data to another matrix. Before copying the data, the method invokes :
m.create(this->size(), this->type());
so that the destination matrix is reallocated if needed. While m.copyTo(m); works flawlessly, the function does not handle the case of a partial overlap between the source and the destination matrices.
When the operation mask is specified, if the Mat::create call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a33fd5d125b4c302b0c9aa86980791a77
Implementation
void copyTo(Mat dst, {Mat? mask}) => mask == null
? cvRun(() => cffi.Mat_CopyTo(ref, dst.ref))
: cvRun(() => cffi.Mat_CopyToWithMask(ref, dst.ref, mask.ref));