OpenCV多图像拼接实现
本示例展示了如何利用OpenCV完成多张图像的简易拼接操作,供读者参考学习。
#include
#include
#include
#include
#include
using namespace std;
using namespace cv;
int main()
{
Mat combine, combine1, combine2;
Mat a = imread("idol1.jpg");
Mat b = imread("idol2.jpg");
Mat c = imread("idol3.jpg");
Mat d = imread("idol4.jpg");
cv::resize(a, a, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
cv::resize(b, b, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
cv::resize(c, c, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
cv::resize(d, d, cv::Size(100, 100), 0, 0, CV_INTER_LINEAR);
//水平拼接
hconcat(a, b, combine1);
hconcat(c, d, combine2);
//垂直拼接
vconcat(combine1, combine2, combine);
namedWindow("Combine", CV_WINDOW_AUTOSIZE);
imshow("Combine", combine);
cv::waitKey(1);
system("pause");
return 0;
}
最终拼接效果如下图所示:

以上内容即为本次分享的全部代码与说明,希望能对各位的学习有所帮助,欢迎继续支持本站。