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 天前
RISC-V特权模式及切换
linux·risc-v
CCF ODC3 天前
【2025CCF中国开源大会】RISC-V 开源生态的挑战与机遇分论坛重磅来袭!共探开源芯片未来
开源·risc-v
禾仔仔3 天前
RISC-V PMA、PMP机制深入分析
risc-v·pmp·pma
LitchiCheng6 天前
RISC-V 开发板 MUSE Pi Pro 搭建 Spacengine AI模型部署环境
人工智能·risc-v
被制作时长两年半的个人练习生7 天前
qemu安装risc-V 64
risc-v
LitchiCheng8 天前
RISC-V 开发板 MUSE Pi Pro OpenCV结合Gstreamer实时显示CSI摄像头
人工智能·opencv·risc-v
LitchiCheng9 天前
RISC-V 开发板 MUSE Pi Pro cpufp测试算力
risc-v
LitchiCheng11 天前
RISC-V 开发板 MUSE Pi Pro USB 测试(3.0 U盘,2.0 UVC摄像头)
linux·运维·risc-v
MounRiver_Studio11 天前
RISC-V IDE MRS2 开发笔记一:volatile关键字的使用
ide·笔记·risc-v
2301_8018217112 天前
实验-设计一个应用系统(计算机组成原理)
cpu·risc-v·计算机组成原理·logisim