美文网首页
[opencv] 图像拼接类 Stitcher

[opencv] 图像拼接类 Stitcher

作者: ericdejavu | 来源:发表于2017-06-14 23:14 被阅读0次

created by Dejavu
(不断更新中)


简介

stitchingOpenCV2.4.0添加的一个新模块,功能是实现图像拼接,所有的相关函数都被封装在Stitcher类当中。

这个类当中我们可能用到的成员函数有createDefault、estimateTransform、composePanorama、stitch。其内部实现的过程是非常繁琐的,包括图像特征的寻找和匹配,摄像机的校准,图像的变形,曝光补偿和图像融合。在OpenCV中调用createDefault函数生成默认的参数即可进行图像拼接。estimateTransformcomposePanorama函数都是比较高级的应用。

c++实现

  • createDefault 实现
//这里用的是opencv2.4.13
#include <opencv2\opencv.hpp>
#include <opencv2\stitching\stitcher.hpp>
using namespace cv;
using namespace std;
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "res.jpg";
int main() {
    char file[10];
    for (int i = 1;i <= 2;i++) {
        sprintf(file, "%d.jpg", i);
        imgs.push_back(imread(file));
    }
    Mat res;
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, res);
    imwrite(result_name, res);
    return 0;
}

图像分辨率 800x600 无gpu加速


拼接图
运行时长与内存占比
可见虽然拼接结果十分不错,但是分辨率为800x600的图像耗时太严重,当然你可以采取gpu加速的方法加快拼接算法运行的速度,但这里我将尝试使用estimateTransformcomposePanorama函数来解决算法慢速问题

相关文章

网友评论

      本文标题:[opencv] 图像拼接类 Stitcher

      本文链接:https://www.haomeiwen.com/subject/flosqxtx.html