opencv 中 phaseCorrelate 方法融合图像拼接

复制代码
#include "quanjing.h"
#include <QApplication>
#include  <QMessageBox>
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <opencv2/opencv.hpp>

using namespace std;
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(){
	Mat imgL = imread("C:/Users/TR/Desktop/quan/2.jpg");
	Mat imgR = imread("C:/Users/TR/Desktop/quan/3.jpg");
	double start = getTickCount();
	Mat grayL, grayR;
	cvtColor(imgL, grayL, COLOR_BGR2GRAY);
	cvtColor(imgR, grayR, COLOR_BGR2GRAY);


	Mat grayL64F, grayR64F;
	grayL.convertTo(grayL64F, CV_64F);
	grayR.convertTo(grayR64F, CV_64F);
	Point shiftPt = phaseCorrelate(grayL64F, grayR64F);
	

	Mat dstImg(imgL.rows, imgR.cols + abs(shiftPt.x), CV_8UC3, Scalar::all(0));
	Mat roiLeft = dstImg(Rect(0, 0, imgL.cols, imgL.rows));
	imgL.copyTo(roiLeft);


	Mat roiRight = dstImg(Rect(-shiftPt.x, 0, imgR.cols, imgR.rows - shiftPt.y));
	Mat cutImg = imgR(Rect(0, shiftPt.y, imgR.cols, imgR.rows - shiftPt.y));
	cutImg.copyTo(roiRight);


	Mat debugImg = dstImg.clone();
	rectangle(debugImg, Point(-shiftPt.x, -shiftPt.y), Point(dstImg.cols-1, imgR.rows - shiftPt.y), Scalar(0, 255, 0), 2, 8);
	imwrite("match.jpg", debugImg);


	double end = getTickCount();
	double useTime = (end - start) / getTickFrequency();
	cout << "use-time : " << useTime << "s" << endl;


	imwrite("C:/Users/TR/Desktop/quan/dst.jpg", dstImg);
	

	QMessageBox::information(this,"xxxx","kkkk");
	
}

quanjing::~quanjing()
{

}

融合后结果:


FR:徐海涛(hunkxu)

相关推荐
OpenAnolis小助手1 天前
玄铁 C950 发布!龙蜥社区加速 RISC-V 云计算落地
云计算·操作系统·龙蜥社区·risc-v
图灵机z2 天前
【操作系统】四、进程管理
linux·服务器·网络·windows·macos·centos·risc-v
jianqiang.xue5 天前
ESP32-S3 运行 Linux 全指南:从 RISC-V 模拟器移植到 8 秒快速启动
linux·stm32·单片机·mongodb·risc-v·esp32s3
AuroBreeze11 天前
RISC-V: Minimal U-mode implementation
linux·c语言·c++·risc-v
VermouthSp12 天前
RISC-V裸机程序(bare-metal-app)
risc-v
国科安芯13 天前
星载电源遥测模块抗辐照RISC-V MCU的性能适配与应用
单片机·嵌入式硬件·无人机·cocos2d·risc-v
国科安芯17 天前
抗辐照MCU在高空长航时无人机热管理系统中的可靠性研究
单片机·嵌入式硬件·架构·无人机·cocos2d·risc-v
开开心心就好1 个月前
内存清理软件灵活设置,自动阈值快捷键清
运维·服务器·windows·pdf·harmonyos·risc-v·1024程序员节
国科安芯1 个月前
基于RISC-V架构的抗辐照MCU在空间EDFA控制单元中的可靠性分析
单片机·嵌入式硬件·性能优化·架构·risc-v·安全性测试