?openv版本: opencv249?
?vs :2010
?qt : 4.85
#include "quanjing.h"#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/stitching/stitcher.hpp>
using namespace std;
using namespace cv;
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "dst1.jpg";
#include <QApplication>
#include <QMessageBox>
using namespace cv;quanjing::quanjing(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags){ui.setupUi(this);connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(btnClick()));
}void quanjing::btnClick(){cv::Mat image2 = cv::imread("C:/Users/TR/Desktop/quan/2.jpg");cv::Mat image3 = cv::imread("C:/Users/TR/Desktop/quan/3.jpg");cv::Mat image4 = cv::imread("C:/Users/TR/Desktop/quan/4.jpg");cv::Mat image5 = cv::imread("C:/Users/TR/Desktop/quan/5.jpg");imgs.push_back(image2);imgs.push_back(image3);imgs.push_back(image4);imgs.push_back(image5);Stitcher stitcher = Stitcher::createDefault(true);// 使用stitch函數進行拼接Mat pano;Stitcher::Status status = stitcher.stitch(imgs, pano);if (status != Stitcher::OK){cout << "Can't stitch images, error code = " << int(status) << endl;QMessageBox::warning(nullptr, "jing gao", QString("Can't stitch images, error code : %1").arg( int(status) ));}else{imwrite("D:/Test/QT/qt04/quanjing/quanjing/555.jpg", pano);Mat pano2 = pano.clone();// 顯示源圖像,和結果圖像imshow("全景圖像1", pano2);}
}quanjing::~quanjing()
{}
準備了四張圖像
2 、3 、4三張 進行stitch,結果如下:
3?、4、5三張進行stitch,結果如下:
2、3、4、5 四張一起進行stitch,結果如下:
經過測試,有時候圖像序列中某兩個連續的出現stitch,錯誤圖像以后的圖像就不會再融合了
感覺? opencv的stitch進行圖像融合,不太穩定,有時候說不出來為什么兩個圖像不能融合,肉眼都可以判斷出是可以融合的
FR:徐海濤(hunkxu)