图像拼接 Stitcher

// mycv.cpp : 定义控制台应用程序的入口点。
//

#include "mycv.h"
#include <iostream>  
#include <fstream>  
#include <string>  
#include "opencv2/opencv_modules.hpp"  
#include "opencv2/highgui/highgui.hpp"  
#include "opencv2/stitching.hpp"
using namespace std;
using namespace cv;
using namespace cv::detail;

int main()
{
    vector<Mat> imgs;    //输入9幅图像
    Mat img;
    img = imread("./pic/1.jpg");
    imgs.push_back(img);
    //img = imread("./pic/2.jpg");
    //imgs.push_back(img);
    img = imread("./pic/3.jpg");
    imgs.push_back(img);
    //img = imread("./pic/4.jpg");
    //imgs.push_back(img);
    //img = imread("./pic/5.jpg");
    //imgs.push_back(img);
    

    int num_images = 5;

    Mat pano;    //全景图像
    Stitcher::Mode mode = Stitcher::SCANS;
    Ptr<Stitcher> stitcher = Stitcher::create(mode, false);//定义全景图像拼接器
    Stitcher::Status status = stitcher->stitch(imgs, pano);//图像拼接
    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << int(status) << endl;
        return -1;
    }

    imwrite("pano.jpg", pano);    //存储图像
    return 0;
}
原文地址:https://www.cnblogs.com/hsy1941/p/14505371.html