opencv,c++图像拼接
程序员文章站
2022-05-16 10:38:14
...
使用opencv里的stitcher进行拼接
#include <stdio.h>
#include <iostream>
#include <sstream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include <opencv2/stitching/stitcher.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat pano;
vector<Mat>imgs;
string tem;
string Input = "D:\\image\\";//读取图片
for (int Num = 0; Num < 10; Num++)//文件夹里前10张图
{
//直接使用to_string()函数
string output = Input + to_string(Num) + ".bmp";
Mat image = imread(output);
tem.clear();
imgs.push_back(image);
}
double t1 = (double)cvGetTickCount();
Stitcher stitcher = Stitcher::createDefault(false);
Stitcher::Status status = stitcher.stitch(imgs, pano);
double t2 = (double)cvGetTickCount();
double t;
t = (t2 - t1) / (cvGetTickFrequency() * 1000);//拼接处理时间
cout << "图像拼接处理时间为: " << t << "ms" << endl;
imgs.clear();
imshow("resultMat1", pano);
imwrite(out + "0.bmp", pano);
waitKey(0);
return 0;
}
推荐阅读
-
python用opencv批量截取图像指定区域的方法
-
python opencv判断图像是否为空的实例
-
荐 Python数字图像处理——OpenCV实例解析
-
OpenCV与图像处理—图像基本操作
-
基于OpenCV的PHP图像人脸识别技术
-
python opencv 实现读取、显示、写入图像的方法
-
python+opencv 读取文件夹下的所有图像并批量保存ROI的方法
-
荐 图像轮廓(二)【OpenCV&Python】
-
OpenCV中的新函数connectedComponentsWithStats使用(python和c++实例)
-
【two 打卡】图像处理基础 python+opencv(超基础)