//十分牛逼的图像拼接程序
#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "result.jpg";
int main(int argc, char* argv[])
{
Mat img=imread("3.jpg");
imgs.push_back(img);
img=imread("1.jpg");
imgs.push_back(img);
img=imread("2.jpg");
imgs.push_back(img);
/*img = imread("huanan4.jpg");
imgs.push_back(img);*/
Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
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<<"xieru"<<endl;
return 0;
}
给份例子:
Result :