private Mat addTo(Mat matA, Mat matB) {
Mat m = new Mat(matA.rows(), matA.cols() + matB.cols(), matA.type());
int aCols = matA.cols();
int aRows = matA.rows();
m.rowRange(0, aRows-1).colRange(0, aCols-1) = matA;
m.rowRange(0, aRows-1).colRange(aCols, (aCols*2)-1) = matB;
return m;
}
I didn't try to run it, but I believe it will work. I assume matA
and matB will have same size and same type. Even if it doesn't work, there must be some little syntax errors or etc. You shouldn't be putting pixels values by using 4 for loops!