opencv 图像拼接



#include "stdafx.h"
#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";

//void printUsage();
//int parseCmdArgs(int argc, char** argv);

int main(int argc, char* argv[])
{

Mat img=imread("1.jpg");
imgs.push_back(img);
img=imread("2.jpg");
imgs.push_back(img);
img=imread("3.jpg");
imgs.push_back(img);

Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);

cv::TickMeter tm;
tm.start();
Stitcher::Status status = stitcher.stitch(imgs, pano);
tm.stop();
cout<<tm.getTimeMilli()<<endl;
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}

imwrite(result_name, pano);
system("pause");
return 0;
}



opencv 图像拼接_第1张图片 opencv 图像拼接_第2张图片

result:



你可能感兴趣的:(拼接)