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)

相关推荐
RISCV_Explorer4 天前
RISC-V内存属性配置深度专题——Svpbmt页表位、PMA优先级与设备访问策略
risc-v
RISCV_Explorer5 天前
RISC-V处理器性能优化:从指令集到微架构的协同设计
后端·risc-v
RISCV_Explorer7 天前
RISC-V启动与运行时规范机制解析——BRS约定、HSM多核启动与设备树要求
后端·risc-v
@嵌入式扫地僧13 天前
国产 RISC-V 机器人关节 MCU 量产落地解析:硬件 EtherCAT 支持与进口替代完整指南
机器人·risc-v·ethercat·国产化替代·机器人关节mcu
论迹复利15 天前
设计 RISC-V PLIC 中断嵌套:threshold 一个寄存器当“优先级闸门“
risc-v·freertos 移植
右耳朵猫AI17 天前
Python周刊2026W36 | Python 3.15候选版、RISC-V获CPython支持、PEP 843、asyncio修复
python·sqlite·risc-v
hongmai66688820 天前
ESP32-WROVER-IE-N4R8:外接天线+8MB内存,专治信号焦虑
笔记·单片机·嵌入式硬件·microsoft·risc-v
花 满 楼21 天前
RISC-V APLIC 中断模块总结——第二篇
单片机·嵌入式硬件·mcu·risc-v
论迹复利22 天前
FreeRTOS 在 RISC-V 上是如何“点火“的 —— 从 main() 到第一个任务的完整链路
java·开发语言·risc-v
花 满 楼23 天前
RISC-V APLIC 中断模块总结——第一篇
mcu·risc-v·中断·aplic