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)

相关推荐
黄交大彭于晏17 小时前
risc_v_boot - RISC-V 的引导是什么样的?
驱动开发·risc-v
老子姓李!1 天前
【GD32】《当RISC-V撞上Wi-Fi 6:GD32VW553的“芯“动初体验》
单片机·嵌入式·risc-v·iot·gd32
是qiqi呀~2 天前
聊一聊:ARM与RISC-V架构
arm开发·单片机·risc-v
禾仔仔5 天前
RISC-V汇编学习(五)—— 汇编实战、GCC内联汇编(基于芯来平台)
汇编·risc-v·内联汇编·abi规则
禾仔仔6 天前
RISC-V汇编学习(四)—— RISCV QEMU平台搭建(基于芯来平台)
汇编·qemu·risc-v·芯来科技
瑶光守护者7 天前
并行计算编程模型的发展方向与RISC-V的机遇
人工智能·笔记·学习·架构·risc-v
luoganttcc10 天前
riscv-rust 是一个用 Rust 编写并编译为 WebAssembly 的RISC-V处理器和外围设备模拟器项目
rust·wasm·risc-v
禾仔仔11 天前
RISC-V汇编学习(三)—— RV指令集
汇编·risc-v·指令集
自不量力的A同学11 天前
香橙派首款高性能开源 RISC-V 开发板 OrangePi RV 即将开售
risc-v