1、图像拼接基本步骤
- 对每幅图进行特征点提取
- 对特征点进行匹配
- 进行图像配准
- 把图像拷贝到另一幅图像的特定位置
- 对重叠边界进行特殊处理
2、利用SUFR、SIFT、ORB算子提取特征点进行拼接
参考链接:https://www.cnblogs.com/skyfsm/p/7411961.html
3、利用Stitch模块进行拼接
#include<iostream>
#include<opencv2\opencv.hpp>
#include<opencv2\highgui\highgui.hpp>
#include<opencv2\stitching.hpp>
using namespace cv;
using namespace std;
bool try_use_gpu = false;
vector<Mat> imgs;
string result_name = "result";
int main()
{
Mat img1 = imread("1.jpg");
Mat img2 = imread("2.jpg");
Mat img3 = imread("3.jpg");
if (img1.empty() || img2.empty() || img3.empty()){
cout << "Fail to read imgs" << endl;
return -1;
}
imgs.push_back(img1);
imgs.push_back(img2);
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 = " << status << endl;
return -1;
}
namedWindow(result_name);
imshow(result_name, pano);
imwrite(result_name, pano);
waitKey();
return 0;
}
说明:stitch 可以进行多张图片的拼接(超过两张图片),但是时间较慢,耗时,实时性不高。