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)

相关推荐
国科安芯3 天前
抗辐照MCU芯片在低轨商业卫星原子钟中的适配与优化
单片机·嵌入式硬件·fpga开发·架构·risc-v
云澈ovo6 天前
RISC-V 架构适配:开源 AI 工具链的跨平台编译优化全流程(附实战指南)
架构·开源·risc-v
Blossom.1188 天前
用一颗MCU跑通7B大模型:RISC-V+SRAM极致量化实战
人工智能·python·单片机·嵌入式硬件·opencv·机器学习·risc-v
矜辰所致16 天前
沁恒微 RISC-V 芯片开发工具 MounRiver Studio 使用
ide·沁恒微·开发工具·risc-v·mrsii
矜辰所致18 天前
【导航】沁恒微 RISC-V 蓝牙 入门教程目录 【快速跳转】
沁恒微·蓝牙·risc-v·ble·ch585
国科安芯23 天前
AS32S601ZIT2型MCU:基于RISC-V架构的抗辐照设计与试验评估
网络·单片机·嵌入式硬件·fpga开发·架构·硬件架构·risc-v
Eloudy23 天前
全文 -- Vortex: Extending the RISC-V ISA for GPGPU and 3D-Graphics Research
gpu·risc-v·arch
慧都小项24 天前
Parasoft助力RISC-V芯片量产:提供高可靠软件测试方案
软件测试·risc-v·芯片·parasoft
京雨24 天前
关于RISC-V 中断处理的分析
单片机·嵌入式硬件·risc-v
京雨25 天前
RISC-V 中的 Wait For Interrupt 指令 (wfi) 详解
risc-v