#include "rebuildhandle.h"
#include <QDebug>
rebuildHandle::rebuildHandle(QObject *parent): QObject(parent)
{
}
void rebuildHandle::perform()
{
readSourceImg();
performStep4();
}
void rebuildHandle::readSourceImg()
{
QDir sourceImgDir("../CtrlGUI/cal/after");
QStringList filter("*.bmp");
QFileInfoList imgInfoList = sourceImgDir.entryInfoList(filter,QDir::Files,QDir::Time|QDir::Reversed);
for (int i = 0; i < imgInfoList.count(); i++)
{
sourceImgs.append(imread(imgInfoList.at(i).filePath().toStdString(),0));
}
}
void rebuildHandle::performStep4()
{
Mat_<double> target(964,1292,CV_64FC1);//最终相位
// 求出三个频率的相位主值
for(int i=0;i<964;i++)
{
for(int j=0;j<1292;j++)
{
double indexHigh=0;double indexMid=0;double indexLow=0;
indexHigh = atan2((sourceImgs.at(3).ptr<double>(i)[j]-sourceImgs.at(1).ptr<double>(i)[j]),
(sourceImgs.at(2).ptr<double>(i)[j]-sourceImgs.at(0).ptr<double>(i)[j]));
indexMid = atan2((sourceImgs.at(7).ptr<double>(i)[j]-sourceImgs.at(5).ptr<double>(i)[j]),
(sourceImgs.at(6).ptr<double>(i)[j]-sourceImgs.at(4).ptr<double>(i)[j]));
indexLow = atan2((sourceImgs.at(11).ptr<double>(i)[j]-sourceImgs.at(9).ptr<double>(i)[j]),
(sourceImgs.at(10).ptr<double>(i)[j]-sourceImgs.at(8).ptr<double>(i)[j]));
QCoreApplication::processEvents();
indexHigh += 3.14159;
indexMid += 3.14159;
indexLow += 3.14159;
double indexTmp1=0;double indexTmp2=0;
indexTmp1=round((indexMid*5-indexHigh)/(2*3.14159));
indexTmp2=indexHigh+indexTmp1*2*3.14159;
double indexTarget1=0;double indexTarget2=0;
indexTarget1=round((indexLow*20-indexTmp2)/(10*3.14159));
indexTarget2=indexTmp2+indexTarget1*10*3.14159;
target.ptr<double>(i)[j] = indexTarget2;
}
}
fitPhase(target);
}
void rebuildHandle::fitPhase(Mat &sourceMat)
{
Mat height(sourceMat.rows,sourceMat.cols,CV_8UC1);//最终显示结果
QFile dataFile("../CtrlGUI/cal/pointCloud.txt");
QTextStream stream;
stream.setDevice(&dataFile);
dataFile.open(QIODevice::Text|QIODevice::ReadWrite);
for(int i=0;i<sourceMat.rows;i++)
{
for(int j=0;j<sourceMat.cols;j++)
{
double tmpa = pow((sourceImgs.at(3).ptr<double>(i)[j]-sourceImgs.at(1).ptr<double>(i)[j]),2);
double tmpb = pow((sourceImgs.at(2).ptr<double>(i)[j]-sourceImgs.at(0).ptr<double>(i)[j]),2);
if(sqrt(tmpa+tmpb)<=30)
{
height.ptr(i)[j] = 0;
}
else
{
height.ptr(i)[j] = 5-sourceMat.ptr<double>(i)[j];
stream<<i<<" "<<j<<" "<<height.ptr(i)[j]<<endl;
}
}
}
dataFile.close();
Mat att;
applyColorMap(height,att,COLORMAP_BONE);
imshow("phase",att);
}
Qt+Opencv实现四步相移
2星 需积分: 48 9 浏览量
2020-05-14
12:21:32
上传
评论 3
收藏 1KB RAR 举报
De_Lieber
- 粉丝: 6
- 资源: 5
最新资源
- 微软常用运行库 游戏运行库 VC++各个版本
- 微信小程序开发教程.pptx
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- 锐捷网络认证中心网络管理.pdf
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- SD8233LF是一款用于单按键触摸及接近感应开关,其用途是替代传统的机械型开关芯片IC
- 基于YOLOv5的烟雾火焰检测算法研究
- 基于STM32的联合调试侦听设备解决方案原理图PCB源文件调试工具视频(大赛作品)
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈