merge images opencv c++ code example
Example: merge images opencv c++
#include <opencv2\opencv.hpp>
using namespace cv;
int main()
{
Mat3b img1 = imread("path_to_image_1");
Mat3b img2 = imread("path_to_image_2");
int rows = max(img1.rows, img2.rows);
int cols = img1.cols + img2.cols;
Mat3b res(rows, cols, Vec3b(0,0,0));
img1.copyTo(res(Rect(0, 0, img1.cols, img1.rows)));
img2.copyTo(res(Rect(img1.cols, 0, img2.cols, img2.rows)));
imshow("Img 1", img1);
imshow("Img 2", img2);
imshow("Result", res);
waitKey();
return 0;
}