图像拼接(类stitcher 用于图像拼接)
2015-11-03 20:07
281 查看
图像拼接类stitcher
拼接类stitcher 的头文件为:#include
"opencv2/stitching/stitcher.hpp"
1、Stitcher::createDefault
使用默认参数创建一个拼接器
C++: Stitcher Stitcher::createDefault(bool try_use_gpu=false)
2、Stitcher::estimateTransform
这些函数尝试匹配给定的图像和去估计每个摄像机的旋转
Note
Use the functions only if you’re aware of the stitching pipeline, otherwise use Stitcher::stitch().
(注意:只有你熟悉拼接的流程情况使用这个函数,否则使用Stitcher::stitch())
C++: Status Stitcher::estimateTransform(InputArray images)
C++: Status Stitcher::estimateTransform(InputArray images,const
std::vector<std::vector<Rect>>& rois)
3、Stitcher::stitch
这些函数用于拼接给定的图像
C++: Status Stitcher::stitch(InputArray images,
OutputArray pano)¶
C++: Status Stitcher::stitch(InputArray images,
const std::vector<std::vector<Rect>>& rois, OutputArray pano)
Parameters:images –
Input images(输入图像)
rois –
Region of interest rectangles(感兴趣矩形区域)
pano –
Final pano
Returns:Status code.
简单示例
#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector<Mat> imgs; //定义一个Mat类型的向量
string result_name = "result.jpg"; //输出图像的名字
int main(int argc, char* argv[])
{
Mat img1 = imread("E:\\图片\\图像拼接\\1.jpg");//E:\\图片\\图像拼接\\1.jpg
if (img1.empty())
{
cout << "img1 Can't read image '" << endl;
return -1;
}
imshow("图1",img1);
imgs.push_back(img1);
Mat img2=imread("E:\\图片\\图像拼接\\2.jpg");
if (img2.empty())
{
cout << "img2 Can't read image '" << endl;
return -1;
}
imshow("图2",img2);
imgs.push_back(img2);
Mat img3=imread("E:\\图片\\图像拼接\\3.jpg");
if (img3.empty())
{
cout << "img3 Can't read image '" << endl;
return -1;
}
imshow("图3",img3);
imgs.push_back(img3);
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;
}
imshow("拼接图",pano);
imwrite(result_name, pano);
waitKey();
return 0;
}
拼接类stitcher 的头文件为:#include
"opencv2/stitching/stitcher.hpp"
1、Stitcher::createDefault
使用默认参数创建一个拼接器
C++: Stitcher Stitcher::createDefault(bool try_use_gpu=false)
2、Stitcher::estimateTransform
这些函数尝试匹配给定的图像和去估计每个摄像机的旋转
Note
Use the functions only if you’re aware of the stitching pipeline, otherwise use Stitcher::stitch().
(注意:只有你熟悉拼接的流程情况使用这个函数,否则使用Stitcher::stitch())
C++: Status Stitcher::estimateTransform(InputArray images)
C++: Status Stitcher::estimateTransform(InputArray images,const
std::vector<std::vector<Rect>>& rois)
3、Stitcher::stitch
这些函数用于拼接给定的图像
C++: Status Stitcher::stitch(InputArray images,
OutputArray pano)¶
C++: Status Stitcher::stitch(InputArray images,
const std::vector<std::vector<Rect>>& rois, OutputArray pano)
Parameters:images –
Input images(输入图像)
rois –
Region of interest rectangles(感兴趣矩形区域)
pano –
Final pano
Returns:Status code.
简单示例
#include <iostream>
#include <fstream>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/stitcher.hpp"
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector<Mat> imgs; //定义一个Mat类型的向量
string result_name = "result.jpg"; //输出图像的名字
int main(int argc, char* argv[])
{
Mat img1 = imread("E:\\图片\\图像拼接\\1.jpg");//E:\\图片\\图像拼接\\1.jpg
if (img1.empty())
{
cout << "img1 Can't read image '" << endl;
return -1;
}
imshow("图1",img1);
imgs.push_back(img1);
Mat img2=imread("E:\\图片\\图像拼接\\2.jpg");
if (img2.empty())
{
cout << "img2 Can't read image '" << endl;
return -1;
}
imshow("图2",img2);
imgs.push_back(img2);
Mat img3=imread("E:\\图片\\图像拼接\\3.jpg");
if (img3.empty())
{
cout << "img3 Can't read image '" << endl;
return -1;
}
imshow("图3",img3);
imgs.push_back(img3);
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;
}
imshow("拼接图",pano);
imwrite(result_name, pano);
waitKey();
return 0;
}
相关文章推荐
- MySQLdb
- OC 协议
- getRequestDispatcher()与sendRedirect()的区别
- T-SQL学习之路之数据库完整性之参照完整性
- 运算符优先级口诀
- IAR 环境安装【TI CC2540开发版 New SmartRF】
- viso2010从mysql中导出ER图
- viso2010从mysql中导出ER图
- python里面区分ascii码与unicode码
- A Simple Study on Kali Linux
- JVM类加载器
- hihocoder 1145
- nginx autoindex
- 文艺篇----《转机》[短文]
- 微信扫码下载APK解决方案
- adr adrl ldr mov总结整理
- SparkSQL与Hive的应用关系
- Codevs_P3185 队列练习1
- Oracle EBS工作流表Subject等字段取值为空解决方法
- iOS模糊效果使用第三方库FXBlurView