失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > opencv4.3 Stitcher图像拼接方法——学习笔记1

opencv4.3 Stitcher图像拼接方法——学习笔记1

时间:2023-05-16 03:57:10

相关推荐

opencv4.3 Stitcher图像拼接方法——学习笔记1

鉴于opencv2和3版本Sticher图像拼接方法在4版本不能用的情况,我们对其进行改进,但是Sticher拼接对重合比较明显的可以拼接,不明显的拼接红外图像会报错。

#include <iostream>#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/imgproc/imgproc.hpp>#include<opencv2/stitching.hpp>#include <opencv.hpp>using namespace std;using namespace cv;bool try_use_gpu = false;vector<Mat> imgs;Stitcher::Mode mode = Stitcher::PANORAMA;string result_name = "dst1.jpg";int main(int argc, char * argv[]){Mat img1 = imread("7.jpg");Mat img2 = imread("8.jpg");Mat dst1;imshow("p1", img1);imshow("p2", img2);/*hconcat(img1, img2, dst1);//水平拼接imshow("dst1", dst1);*/if (img1.empty() || img2.empty()){cout << "Can't read image" << endl;return -1;}imgs.push_back(img1);imgs.push_back(img2);Mat pano;Ptr<Stitcher> stitcher = Stitcher::create(mode);Stitcher::Status status = stitcher->stitch(imgs, pano);// 使用stitch函数进行拼接if (status != Stitcher::OK){cout << "Can't stitch images, error code = " << int(status) << endl;return -1;}imwrite(result_name, pano);Mat pano2 = pano.clone();// 显示源图像,和结果图像imshow("全景图像", pano);if (waitKey() == 27)return 0;}

如果觉得《opencv4.3 Stitcher图像拼接方法——学习笔记1》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。