zoukankan      html  css  js  c++  java
  • 图像拼接 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;
    }
  • 相关阅读:
    每天一个linux命令
    Python 面向对象-下篇
    Python 面向对象-上篇
    何时会发生隐式类型转换
    C++类型检查
    无符号保留原则
    bool类型为什么可以当做int
    在类的外部定义成员函数注意形式
    局部类
    命名规范
  • 原文地址:https://www.cnblogs.com/hsy1941/p/14505371.html
Copyright © 2011-2022 走看看