Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy a row of a Mat to another Mat's column in OpenCv?

Tags:

opencv

I have two Mat:

A:
size(1,640)
B:
size(640,480)

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?

like image 584
Treper Avatar asked Mar 29 '13 04:03

Treper


1 Answers

You were on the right track! Mat:col is the matching tool to use :)

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.

Example code:

B.col( 0 ) = A.col( 0 ); // won't work as expected

A.col( 0 ).copyTo( B.col(0) ); // that's fine
like image 148
dom Avatar answered Oct 23 '22 17:10

dom