两张图像收尾相接

Opencv有自带函数:

cv::vconcat(a, b, combine);

  自己无聊造一个轮子:

	Mat a = imread("**********.jpg");
	Mat b = imread("**********.jpg");
	resize(b, b, a.size(), 0, 0, INTER_LINEAR);

	Mat combine;
	std::vector<uchar> vecImage(0);
	uchar *src = a.data;
	uchar *dest = b.data;

	std::vector<uchar> vecsrc(src, src + a.channels()*a.cols*a.rows);
	std::vector<uchar> vecdest(dest, dest +b.channels()*b.cols*b.rows);
	vecImage.insert(vecImage.end(), vecsrc.begin(), vecsrc.end());
	vecImage.insert(vecImage.end(), vecdest.begin(), vecdest.end());

	cv::Mat mat = cv::Mat(vecImage);//将vector变成单列的mat
	combine = mat.reshape(a.channels(), a.rows+b.rows).clone();//

 

posted @ 2020-07-22 10:05  盖世猪猪侠  阅读(149)  评论(0编辑  收藏  举报