OpenCV实现多图像拼接成一张大图
实现多图像拼接成一张大图
主要为大家详细介绍了OpenCV实现多图像拼接成一张大图,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了OpenCV实现多图像拼接成大图的具体代码,供大家参考,具体内容如下
开始尝试merge函数,具体如下:
定义四个矩阵A,B,C,D。得到矩阵combine。
#include
#include 
#include 
#include 
using namespace std;
using namespace cv;
int main()
{
 cv::Mat a = (cv::Mat_(2,2)<<1,2,3,4);
 cv::Mat b = (cv::Mat_(2,2)<<5,6,7,8);
 cv::Mat c = (cv::Mat_(2,2)<<9,10,11,12);
 cv::Mat d = (cv::Mat_(2,2)<<13,14,15,16);
 std::vector v1;
 v1.push_back(a);
 v1.push_back(b);
 v1.push_back(c);
 v1.push_back(d);
 cv::Mat combine;
 cv::merge(v1, combine);
 cout << "combine=" <
#include 
#include 
#include 
using namespace std;
using namespace cv;
int main()
{
 cv::Mat a = (cv::Mat_(2,2)<<1,2,3,4);
 cv::Mat b = (cv::Mat_(2,2)<<5,6,7,8);
 cv::Mat c = (cv::Mat_(2,2)<<9,10,11,12);
 cv::Mat d = (cv::Mat_(2,2)<<13,14,15,16);
 Mat combine,combine1,combine2;
 hconcat(a,b,combine1);
 hconcat(c,d,combine2);
 vconcat(combine1,combine2,combine);
 //namedWindow("Combine",CV_WINDOW_AUTOSIZE);
 //imshow("Combine",combine);
 cout<<"Combine=:"<
#include 
#include 
#include 
using namespace std;
using namespace cv;
int main()
{
 //cv::Mat a = (cv::Mat_(2,2)<<1,2,3,4);
 //cv::Mat b = (cv::Mat_(2,2)<<5,6,7,8);
 //cv::Mat c = (cv::Mat_(2,2)<<9,10,11,12);
 //cv::Mat d = (cv::Mat_(2,2)<<13,14,15,16);
 Mat combine,combine1,combine2;
 Mat a=imread("1.jpg");
 Mat b=imread("2.jpg");
 Mat c=imread("3.jpg");
 Mat d=imread("4.jpg");
 hconcat(a,b,combine1);
 hconcat(c,d,combine2);
 vconcat(combine1,combine2,combine);
 namedWindow("Combine",CV_WINDOW_AUTOSIZE);
 imshow("Combine",combine);
 waitKey(0);
 //cout<<"Combine=:"<以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。