zoukankan      html  css  js  c++  java
  • 多幅图像全景拼接

    全景拼接在OpenCv中可以利用Stitch类方便实现,Stitching类将图像的矫正,对齐,图像映射,拼接,融合全部包括进去了。

    这里有一个例子可以对三幅图像进行全景拼接:

    // 图像拼接.cpp : 定义控制台应用程序的入口点。
    //
    #include <iostream>
    #include <fstream>
    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/stitching/stitcher.hpp"
    #include <sstream>
    #include <string>
    
    using namespace std;
    using namespace cv;
    
    bool try_use_gpu = false;
    vector<Mat> imgs;
    string result_name;// = "result.jpg";
    
    string IntToString(int num)
    {
        stringstream ss;
        string s;
        ss << num;
        ss >> s;
        return s;
    }
    
    string str = "quanjing\";
    int main(int argc, char* argv[])
    {
        result_name = str + "stichimg.jpg";
        for (int i = 1; i <=3; ++i)
        {
            Mat img = imread(str + IntToString(i) + ".jpg", 1);
            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;
        }
    
        namedWindow("pano", 0);
        imshow("pano", pano);
        imwrite(result_name, pano);
        waitKey(0);
        return 0;
    }


    测试了部分图片,发现相邻图像之间的重复区域过小会拼接失败。实际上,这些图像之间还是有比较多的重复区域,利用其它的拼接软件可以实现拼接。

    因此,要获取好的拼接效果还要自行研究

    部分疑问:

    1 图像拼接中如何将多幅图像对准在同一像素坐标系下面

    http://stackoverflow.com/questions/24563173/stitch-multiple-images-using-opencv-python

    2 柱面投影模型的实现

    3 图像的对比度调整融合

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    Matlab2014b中也加入了Panorama模块

    http://cn.mathworks.com/help/vision/examples/feature-based-panoramic-image-stitching.html

  • 相关阅读:
    让PHP更快的提供文件下载
    thinkphp5接入QQ第三方登录
    tp5隐藏index.php
    thinkphp5 表达式
    后台无限级分类添加的实现方式
    PHP系统左侧菜单栏的管理与实现
    mongoDB基本命令
    Java基础-反射和注解
    Java基础-多线程
    Java基础-网络编程
  • 原文地址:https://www.cnblogs.com/adong7639/p/4274079.html
Copyright © 2011-2022 走看看