OpenCV 把兩張圖在同一視窗顯示的方法(圖片複製,圖片擴展大小,圖片串接)

OpenCV 把兩張圖在同一視窗顯示的方法(圖片複製,圖片擴展大小,圖片串接)

OpenCV 把兩張圖在同一視窗顯示的方法(圖片複製,圖片擴展大小,圖片串接)


資料來源: https://mp.weixin.qq.com/s?__biz=MzA4MDExMDEyMw==&mid=2247487013&idx=2&sn=bdd0f0ba9fbbdb78ebf1c282d3aa00ed&chksm=9fa87961a8dff07724bcbcec7b750cbb51a6a8be189e16270ce96cf1c1d73d26c8f57ce710f2&scene=0&xtrack=1&key=78f1897f314d4506e6872bfca9902cd59061a8fbff6664e06f63f053a447651e8e2be7568e7fcf2b0589094da82bdef193eb0769aa8f6478de8d33e95f68df78a37bbc791ac737da9e68b32e736d25bc&ascene=1&uin=MjIwODk2NDgxNw%3D%3D&devicetype=Windows+10&version=62060833&lang=zh_TW&pass_ticket=XCPLH8gweiYSFA2LzOMouAt51NbwKSAFIYCe9FVTdtdN7jfOs0X0Pi6U5M7I76ed


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);

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *