OpenCV 把兩張圖在同一視窗顯示的方法(圖片複製,圖片擴展大小,圖片串接)
OpenCV 把兩張圖在同一視窗顯示的方法(圖片複製,圖片擴展大小,圖片串接)
Mat src1 = imread("D:/images/lena.png"); Mat src2 = imread("D:/images/t3.jpg"); imshow("src1", src1); imshow("src2", src2); // 构建新图像的大小 int width = src1.cols + src2.cols; int height = max(src1.rows, src2.rows); Mat two = Mat::zeros(Size(width, height), src1.type()); // 构建ROI Rect r1(0, 0, src1.cols, src1.rows); Rect r2(0, 0, src2.cols, src2.rows); r2.x = src1.cols; // 内容copy src1.copyTo(two(r1)); src2.copyTo(two(r2)); imshow("two images demo", two); waitKey(0);