且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在OpenCV中更新Mat的子矩阵

更新时间:2023-10-07 08:51:22

最快的方法之一是设置一个标题矩阵指向要更新的列/行的范围,例如this:

One of the quickest ways is setting a header matrix pointing to the range of columns/rows you want to update, like this:

Mat aux = X.colRange(4,7).rowRange(4,8); // you are pointing to submatrix 4x3 at X(4,4)

现在,矩阵到aux(但实际上你会将它复制到X,因为aux只是一个指针):

Now, you can copy your matrix to aux (but actually you will be copying it to X, because aux is just a pointer):

mat43.copyTo(aux);

就是这样。