Copy two images into one image using OpenCV 2.4.2

I am trying to copy two images into one large image, but, unfortunately, I cannot paste only one image with the following attempt:

void showTwoImages(Mat imageOne, Mat imageTwo, string title) { int totalCol = imageOne.cols+imageTwo.cols; int totalRow = imageOne.rows; Mat totalImage(Size(totalCol, totalRow), 8, 3); imageOne.copyTo(totalImage(Rect(0,0,imageOne.cols, imageOne.rows))); viewImage(totalImage, title); } 

My mistake:

enter image description here

Unfortunately, I do not get a specific error from Xcode, but I refer to the assembler code, so I can not determine the error that occurred.

+4
source share
1 answer

Change

 Mat totalImage(Size(totalCol, totalRow), 8, 3); 

to

 Mat totalImage(Size(totalCol, totalRow), imageOne.type()); 
+5
source

Source: https://habr.com/ru/post/1443533/


All Articles