Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

this is a quite common pitfall.

Mat r = b.row(i);

makes a new Mat header, with data pointing to row i of the original Mat. so far, so good. but it's a copy !.

assigning another Mat to it will NOT change the original Mat ! so:

b.row(i) = a.row(i);

does not do anything (again, since you assign it to a copy)

a.row(i).copyTo(b.row(i));

would have done, what you probably expected. but since you try to do that for every row anyway, rather use a plain:

a.copyTo(b);

or even (same):

b = a.clone();