图像拼接Stitcher中estimateTransform、composePanorama函数用法

最近在做视频拼接,了解到OPENCV自带图像拼接stitcher类,想看看效果。于是就在网上搜了搜stitcher类的用法,发现网上大家发的都来自一篇,或者说都是opencv自带的例子stitching.cpp。这个类当中我们可能用到的成员函数有createDefault、estimateTransform、composePanorama、stitch。但例子只用到createDefaultstitch,实现的例子为:

  1.   Stitcher stitcher = Stitcher::createDefault(false);  //不使用GPU加速
  2.   Stitcher::Status status = stitcher.stitch(imgs, pano);  //imgs为输入图像组成的vector,pano为拼接结果

因为我做的视频拼接,这样子每次做就太慢了,我想先计算矩阵,以后直接调用,就不知道estimateTransform、composePanorama怎么用,opencv里也没有详细说明。废话不多说了,给出我的使用示例,希望对来者有所帮助,不走弯路。

  1. #include <stdio.h>  
  2. #include <iostream>  
  3. #include <vector>  
  4.   
  5. #include "opencv2/highgui/highgui.hpp"  
  6. #include "opencv2/stitching/stitcher.hpp"  //stitching 影像拼接  
  7. using namespace cv;  
  8. using namespace std;  
  9.   
  10. int main()  
  11.   
  12. {  
  13.   
  14.    IplImage* img_1 = cvLoadImage("3.jpg");  
  15.    IplImage* img_2 = cvLoadImage("4.jpg");  
  16.     
  17.    vector<Mat> imgs;  
  18.      
  19.    imgs.push_back(img_1);  
  20.    imgs.push_back(img_2);  
  21.     //拼接  
  22.   
  23.   Mat pano;  
  24.   Stitcher stitcher = Stitcher::createDefault(false);  
  25.   stitcher.estimateTransform(imgs);
  26.    //stitcher.composePanorama(pano); //使用之前的图片集imgs
  27.    stitcher.composePanorama(imgs,pano);//可以加入新的图片集imgs(保证与之前的大小数量一致)
  28.   imwrite("stitching image.jpg", pano);  
  29.   imshow("拼接",pano);  
  30.   waitKey(0);  
  31.   return 0;  
  32. }



【世事如此】知道了就简单,不知道就蛋疼!

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值