如何将Mat的一行复制到OpenCv中的另一个Mat的列上? [英] How to copy a row of a Mat to another Mat's column in OpenCv?
本文介绍了如何将Mat的一行复制到OpenCv中的另一个Mat的列上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个Mat:
A:
size(1,640)
B:
size(640,480)
我想将A复制到B的第一列,所以我使用A.copyTo(B.col(0))
.但这失败了.怎么做?
I want to copy A to B's first column so I use A.copyTo(B.col(0))
.But this failed. How to do it?
推荐答案
您在正确的轨道上! Mat:col
是要使用的匹配工具:)
You were on the right track! Mat:col
is the matching tool to use :)
但是要注意,仅将一个col分配给另一个col不会按您预期的那样工作,因为Mat:col
只会为您指定的矩阵列创建一个新的矩阵标题,而没有数据的真实副本.
But beware, simply assigning one col to another one won't work as you may expect it, because Mat:col
just creates a new matrix header for the matrix column you specified and no real copy of the data.
示例代码:
B.col( 0 ) = A.col( 0 ); // won't work as expected
A.col( 0 ).copyTo( B.col(0) ); // that's fine
这篇关于如何将Mat的一行复制到OpenCv中的另一个Mat的列上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文