基于opencv的图像拼接(二): stitch 类

来源:互联网 发布:退款淘宝介入处理过程 编辑:程序博客网 时间:2024/06/01 23:39

关于图像拼接,opencv 库里已经自带了 stitch类,可以很好的实现图像拼接(两张或者多张),匹配效果比很多自己写的要好很多

附上基于stitch的图像拼接,程序比较简单,但是拼接速度较慢,需要7m左右

#include <iostream>#include <opencv2/highgui/highgui.hpp>#include <opencv2/legacy/legacy.hpp>#include <opencv2/stitching/stitcher.hpp>#include <vector>using namespace std;using namespace cv;//调用opencv自带的stitcher库拼接void stitch(vector<Mat> imgs,Mat& resultMat){bool flag = true;Stitcher stitcher = Stitcher :: createDefault(flag);Stitcher::Status status = stitcher.stitch(imgs, resultMat);}int main(){Mat srcImage1 = imread("E:\\my\\pic_save\\angle_y1.jpg", 1);Mat srcImage2 = imread("E:\\my\\pic_save\\angle_x1.jpg", 1);vector<Mat>imgs;imgs.push_back(srcImage1);imgs.push_back(srcImage2);Mat resultMat;stitch(imgs, resultMat);imshow("resultMat1", resultMat);waitKey(0);return 0;}


原创粉丝点击