3,882
社区成员




#include "stdafx.h"
#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
int main(int argc, char* argv[])
{
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "result.jpg";
Mat img1=imread("1.jpg");
Mat img2=imread("2.jpg");
Mat img3=imread("3.jpg");
imgs.push_back(img1);
imgs.push_back(img2);
imgs.push_back(img3);
Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
cout<<"拼接开始"<<endl;
Stitcher::Status status = stitcher.stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
imwrite(result_name, pano);
cout<<"全景拼接完成!"<<endl;
return 0;
}