OpenCV中stitcher的简单应用,利用opencv中自带的sample稍微改编。
#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
vector<Mat> imgs;
string result_name = "E://image1-2.jpg";
int main(int argc, char* argv[])
{
Mat img1 = imread("E://image1.jpg");
Mat img2 = imread("E://image2.jpg");
imgs.push_back(img1);
imgs.push_back(img2);
Mat pano;
Stitcher stitcher = Stitcher::createDefault();
Stitcher::Status status = stitcher.stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << status << endl;
return -1;
}
imwrite(result_name, pano);
return 0;
}