Three-dimensional reconstruction of fringe projection structured light (2) - four-step phase shift + three-frequency heterodyne method

        Continuing from the above:

Three-dimensional reconstruction of stripe projection structured light (1) https://blog.csdn.net/beyond951/article/details/123361852?spm=1001.2014.3001.5501

        To verify the above ideas, this blog mainly solves the phase. First, it repeats the theory of the above blog, and then includes the calculation of the main value of the phase and the phase expansion.

Four-step phase shift + three-frequency heterodyne theoretical derivation

Calculation of main value of phase - four-step phase shift method

        It is difficult to obtain high-precision phase Φ(x, y) through a frame of deformed fringe pattern, and a phase shift algorithm is required to accurately measure the phase. There are many methods for phase shifting the fringe pattern, and the more commonly used method is the N-frame full-period equidistant phase shifting method. The projected sinusoidal fringes move every 1/N of a grating period, and generate a corresponding light intensity function, In(x,y), at this time the phase of the sinusoidal fringes moves 2π/N accordingly. The four-step phase shift algorithm, each phase shift increment is π/2, so the corresponding four deformed fringe patterns can be obtained, here it is assumed that In(x,y)(n=1,2,3,4) represents the nth image light intensity, then:

         The phase function Φ(x,y) that can be calculated from the above is

         Since the phase information is calculated by the arctangent function, the obtained phase values ​​are all discontinuous phases truncated in the interval (-π, π]. In order to obtain a continuous phase distribution, phase unwrapping is required. Three-frequency heterodyne method for phase unwrapping.

Phase Unwrapping—Triple-Frequency Heterodyne Method

        The three-frequency heterodyne method is a time phase expansion method, which is improved on the basis of the three-frequency expansion method. By projecting fringe patterns of three different frequencies onto the surface of the object, a set of fringe patterns modulated by the surface of the object is obtained by shooting, and then the phase of each point is independently expanded along the time series, which can avoid the propagation of errors in principle.

        Three sets of fringe patterns with fringe period numbers t=s-√s,s,s+√s+1 are projected, and three truncated phase patterns are obtained by four-step phase shifting. Afterwards, two heterodynes are performed, and it can be seen that the number of (√s,√s+1) fringe patterns is obtained by the first heterodyne, and the fringe pattern with a fringe period of 1 is obtained by another heterodyne, where the heterodyne That is, the corresponding pixel phase is subtracted.

        First define the expansion operator U[ Φ1,Φ2 ] as follows:

         Among them, NINT(·) is the rounding operation.

        Then the phase distribution of fringe period number 1 obtained by heterodyne is equivalent to Φw(1) which is equivalent to the unfolded phase Φu(1), and the phase unwrapping is carried out step by step with it as the starting phase:

        Among them, v=√s represents the magnification of different heterodyne orders, and k goes to 2 and 3 step by step. The unfolded phase is fitted by the least square method, and the calculated slope is expressed as :

        Then multiply the slope by the maximum number of projected fringes to obtain the final unfolded phase ΔΦ.

         To sum up the above, the retelling is complete, and the code is posted.

Code

Calculation of main value of phase - four-step phase shift method

//*****************四步相移法求解图像的相位主值******************//
//本次实验采用四步相移法+三频外差法
//输入输出:输入位十二张图片;输出为三张不同频率的主值图
vector<Mat> FringeStructuredLight::SolveThePhase(vector<Mat> srcVec)
{
	
}

Phase Unwrapping—Triple-Frequency Heterodyne Method

//*****************三频外差法对四步相移法求的相位进行展开******************//
//本次实验采用四步相移法+三频外差法
//输入输出:输入位三张主值相位图片;输出为相位的展开图
Mat FringeStructuredLight::UnwrappedPhase(vector<Mat> srcVec)
{
	
}

main function

int main()
{
	//********声明一些变量存储相位图和高度**********//
	vector<Mat> heightPhase;
	vector<double> height;
	//********计算参考平面的相位**********//
	string filePath_h0 = "D:*.bmp";
	vector<Mat> imgVec_h0 = Api.ReadImg(filePath_h0);
	//********对文件路径下的十二副图计算三组主值相位**********//
	vector<Mat> mainPhaseVec_h0 = Api.SolveThePhase(imgVec_h0);
	//********相位展开**********//
	Mat unwrapPhase_h0 = Api.UnwrappedPhase(mainPhaseVec_h0);
	return 0;
}

ReadImg function

//*****************读取文件夹里面的图片******************//
vector<Mat> FringeStructuredLight::ReadImg(std::string filepath)
{
	vector<Mat> tempVec;
	std::vector<cv::String> image_files;
	glob(filepath, image_files);
	//最后一张图不读
	for (int i = 0; i < image_files.size()-1; i++)
	{
		Mat temp = imread(image_files[i]);
		tempVec.push_back(temp);
	}
	return tempVec;
}

Show results

        The four-step phase shift + three-frequency heterodyne has a total of twelve pictures, so there are three pictures after the main value of the phase is calculated by the four-step phase-shift method, and the phase expansion picture is finally obtained by the three-frequency heterodyne.

Primary value calculation result

 

 Phase Unwrapping Results

 

         The above will expand the phase diagram and display it through halcon. The next step is to expand the calibration of the phase height model.

Guess you like

Origin blog.csdn.net/beyond951/article/details/123769596