接上面两文:
三维重建之条纹投影结构光(一)https://blog.csdn.net/beyond951/article/details/123361852?spm=1001.2014.3001.5501三维重建之条纹投影结构光(二)——四步相移+三频外差法https://blog.csdn.net/beyond951/article/details/123769596?spm=1001.2014.3001.5501 接下来对相高模型进行标定,其推导过程如下图所示
由上面的推导可以发现,在得到了20个不同的高度及其对应的相位图,开始根据这些进行abc参数的求解,即为相高模型的标定,下面是标定的代码
标定函数:
//*****************根据展开的相位和高度关系进行标定******************//
//输入为20副对应高度和相位图
//输出为一个三通道的Mat矩阵,分别对应标定参数a、b、c
vector<Mat> FringeStructuredLight::Calibration(vector<Mat> heightPhase, vector<double>height)
{
}
标定主程序:
#include "FringeStructuredLight.h"
#include <string>
#include <fstream>
#include <iostream>
FringeStructuredLight Api;
using namespace std;
int main()
{
//********声明一些变量存储相位图和高度**********//
vector<Mat> heightPhase;
vector<double> height;
//********读取文件路径下的图片**********//
cout << "开始计算各个高度的相位展开图" << endl;
//参考平面的相位
string filePath_h0 = "D:\\01-条纹投影结构光\\资料\\h0\\*.bmp";
vector<Mat> imgVec_h0 = Api.ReadImg(filePath_h0);
vector<Mat> mainPhaseVec_h0 = Api.SolveThePhase(imgVec_h0);
Mat phase_h0= Api.UnwrappedPhase(mainPhaseVec_h0);
//二十个标定平面的相位求解
for (int i = 1; i < 21; i++)
{
string filePath = "D:\\01-条纹投影结构光\\资料\\h"+to_string(i)+"\\*.bmp";
vector<Mat> imgVec = Api.ReadImg(filePath);
//********对文件路径下的十二副图计算三组主值相位**********//
vector<Mat> mainPhaseVec = Api.SolveThePhase(imgVec);
//********相位展开**********//
Mat unwrapPhase = Api.UnwrappedPhase(mainPhaseVec)- phase_h0;
heightPhase.push_back(unwrapPhase);
}
cout << "各个高度的相位图展开完毕" << endl;
cout << "将各个高度计算赋值" << endl;
for (int i = 1; i < 21; i++)
{
double temp = 0.25*i;
height.push_back(temp);
}
cout << "各个高度赋值完毕" << endl;
cout << "开始标定" << endl;
vector<Mat> abcMat = Api.Calibration(heightPhase, height);
return 0;
}
但自己重构的结果不是很理想,希望和大家探讨,代码某些细节部分可能有问题,但总体思路是对的。