I know I can do this by copying each element myself, but is there a method that does it for me? I tried mat2.copyTo(mat1.row(0))
but that doesn't work.
Try
Mat mat1row = mat1.row(0);
mat2.copyTo(mat1row);
(assuming mat2 has the same size as the destination row).
That should do the job and is more clear.
Edit: This is even shorter and recommended by the official documentation:
A.row(j).copyTo(A.row(i));
More details on this in the official documentation: http://docs.opencv.org/modules/core/doc/basic_structures.html#Mat%20Mat%3a%3arow%28int%20y%29%20const
Try
destMat.row(i) = (sourceMat.row(i) + 0);
It's not very pretty but it gets the job done. Also see this. Read the comments on Mat::row
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With