inline Mat Mat::clone() const { Mat m; copyTo(m); return m; } void Mat::copyTo( OutputArray _dst ) const { ......//此处省略代码 _dst.create( dims, size, type() );//此处创建了图像存储的新内存 Mat dst = _dst.getMat();//dst由getMat进行初始化 if( data == dst.data ) return; if( total() != 0 ) { const Mat* arrays[] = { this, &dst }; uchar* ptrs[2]; NAryMatIterator it(arrays, ptrs, 2); size_t sz = it.size*elemSize(); for( size_t i = 0; i < it.nplanes; i++, ++it ) memcpy(ptrs[1], ptrs[0], sz);//该处为每个内存像素的复制 } } Mat UMat::getMat(int accessFlags) const { if(!u) return Mat(); // TODO Support ACCESS_READ (ACCESS_WRITE) without unnecessary data transfers accessFlags |= ACCESS_RW; UMatDataAutoLock autolock(u); if(CV_XADD(&a