OpenCV图像直接拼接方法下面链接已做介绍,只是这次我们将使用现成的函数实现,它们是vconcat()和hconcat()。
https://blog.csdn.net/stq054188/article/details/107883955
vconcat()---垂直方向拼接,要求待拼接图像有相同的宽度
hconcat()---水平方向拼接,要求待拼接图像有相同的高度
C++ Demo实例如下:
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat img = imread("1.jpg");
vector<Mat>vImgs;
Mat result;
vImgs.push_back(img);
vImgs.push_back(img);
vImgs.push_back(img);
vconcat(vImgs, result); //垂直方向拼接
//hconcat(vImgs, result); //水平方向拼接
imwrite("result.jpg", result);
return 0;
}
效果: