Object Shape Measurement Based on Brox Optical Flow Estimation and Its Correction Method

: In this work, a new method of measuring surface shape based on Brox optical ﬂow estimation is presented. The measuring system consists of a projector, a measured object and a charge coupled device (CCD) camera. The grating fringes are projected onto the reference plane at a small angle. Two fringe images—before and after placing the measured object on the reference plane—are captured, respectively. Then, the optical ﬂow ﬁeld between two images is evaluated by using Brox optical ﬂow algorithm. The theoretical relationship between the optical ﬂow ﬁeld and the height of the measured surface is established. According to the relationship, the height distribution of the measured object can be retrieved quickly without phase-to-height transformation. However, the calculated height distribution has been found to be deviated from its true value. To solve the problem, a correction scheme suitable for the optical ﬂow method is proposed. By using the correction scheme, the accuracy of the calculated result is greatly improved. Simulations and experiments are completed to verify the feasibility of the proposed method and the accuracy of the correction method. The results show that the proposed method is more accurate than that of the Fourier transform method. Compared with traditional surface shape measurement, the optical ﬂow method has some obvious advantages: (1) Only two frame images are required to recover the height distribution. (2) Relatively simple in measurement process and calculation so less time consuming. (3) Because the optical ﬂow method contains time factor itself, it is more suitable for dynamic measurement. (4) No restrictions on projection pattern.


Introduction
Three-dimensional (3-D) surface shape profilometry is an important method to obtain object shape features, and it has many applications in cultural relic protection, computer vision, surface detection, quality inspection and so on [1][2][3][4]. In surface shape profilometry, a grating fringe image with a gray level of cosine distribution is projected onto the measured object surface by using a projector. The fringes on the measured surface will be deformed due to the modulation of the object surface. Then, the fringe images before and after the deformation are recorded using the camera, from which the shape information of the measured surface can be recovered. Commonly, the information extraction techniques of the measured surface include Fourier transform profilometry (FTP), phase measurement profilometry and the Projection moiré method [5][6][7][8]. Each of these techniques takes the phase of the measured surface as the measured physical parameter. Therefore, to obtain the height distribution of the measured surface, the phase-to-height operation is required.
Different from traditional phase measurement techniques, the optical flow surface shape measurement technique does not measure the phase distribution but the height distribution directly, only requiring two frames before and after deformation. The measurement accuracy of it is equivalent to that of the FTP method [9]. Because the height distribution is calculated point-by-point, the optical flow method is robust to noises [10].
Similar to traditional phase measurement methods, the optical flow method also has the problem of tilt distortion. The calculated height distribution deviates from its true value. In order to overcome the tilt distortion, two approaches have been reported: The first one is the projection fringe correction method [11], which uses the four-step phase shift method to calibrate the phase periods of the projected sinusoidal fringes, forming a uniform spatial periodic fringe. The second one is the generalized fringe projection method [12], which consists of a reference object of a known height to calibrate the parameters in the phase-to-height equation, in which the parameters have a relationship with the uniform distribution of phase on the vertical projection plane. In practice, both approaches have their limitations. The projection fringe correction method, more suitable for measuring large objects, requires that the optical center of the projector and that of the CCD camera are at the same distance from the reference surface. The distribution of the projected fringes needs to be estimated in advance. Especially, different modification is required for a different experiment in the method. These requirements limit the application of this method. Different from the projection fringe correction method, the generalized fringe projection method has high accuracy, but needs to capture a series of images in the experiment, and requires other operations such as phase extracting and phase unwrapping, fringe order offsetting and parameter detecting. Therefore, this method is time-consuming and complex in the experiment process.
In our work, a surface shape measurement system based on Brox optical flow estimation is presented. The setup of the measuring system is simple, consists of a projector, a measured object and a CCD camera, which is depicted in the world coordinate system established on the reference plane. The projector projects a pattern on the reference plane at a small projection angle so that the deformed pattern is small enough to ensure that the optical flow method can be applied. The small deformation of the deformed pattern is evaluated by using Brox optical flow algorithm [13]. Compared with the reported optical flow estimation algorithms in motion analysis [13][14][15], the Brox optical flow algorithm is more robust to noises and has a wider range in displacement measurement. By using the Brox optical flow algorithm to calculate the deformation of the projection fringes, we have completed the following two works. One is that the relationship between the optical flow and the measured height is established on the geometry of the measurement system. Based on this relationship, the distribution of the measured surface is retrieved. Another is the tilt error of the measurement results is found and its correction method is presented. We find that the calculated height distribution deviates from its true value, which is caused not only by the oblique projection but also by the misalignment between the camera and the projector in their distance to the reference surface. Then, a correction method is proposed to solve the problem, which can greatly improve the accuracy of the calculated result. Simulations and actual measurements are carried out to prove the feasibility of the proposed optical flow method and the effectiveness of the proposed tilt correction method. The comparison between the proposed method and the FTP method in experiment measurement is completed to show that the proposed method is effective and accurate in measurement. Many advantages of the newly proposed method are obvious but need to be emphasized: • Compared with existing phase measurement methods, it is simple in setup and operation. Only two frames of the image are captured and used for retrieving the height distribution.

•
Compared with existing methods, it is less time consuming due to retrieving the height distribution directly. The measurement of the surface shape could be completed in less than 8 s.

•
Because the optical flow method contains the time factor itself, it is more suitable for dynamic measurement.

•
Compared with the existing tilt correction method, the newly proposed method is easier to implement and requires no additional operations.

•
There are no strict limits to the projection pattern. Any image with varying gray values can be used for projection.

Introduction of the Brox Optical Flow Algorithm
Brox algorithm, a global method, is a powerful tool for motion analysis. The constraints used in Brox algorithm include the gray value constancy and the gradient constancy, where the latter is particularly helpful for the analysis of translatory motion. The piecewise smooth flow field and multiscale approach are utilized to solve the problem of the discontinuities at the boundaries of objects in the scene and to find the global minimum of the cost functional in a variational formulation in the case of larger displacement.
The brightness of an image point A i (x i , y i ) captured at time t is described by the intensity I i (x i , y i , t), where subscripts denote the variable on the image plane of the camera. After deformation, point According to the brightness constancy, that is , which can be modified with a first-order Taylor approximation, the optical flow constraint equation can be obtained, as shown in Equation (1): where u = ∆x i ∆t and v = ∆y i ∆t are the components of the optical flow field between two frames that are the velocity components of the observation point A i (x i , y i ) in x and y directions. Then, the global deviations of the assumption of brightness constancy and gradient constancy and the assumption of the piecewise smooth flow field are measured by an energy expression-shown in Equation (2)-after taking quadratic penalisers into account: +α Ω Ψ |∇u| 2 + |∇v| 2 dp where (x, y) ∈ Ω, Ω defines the image domain, p = (x, y) T , w = (u, v) T , γ is the weight between two assumptions and α denotes the regularization parameter greater than 0. Ψ x 2 = √ x 2 + ε 2 is an increasing concave function, ε is the small positive constant, which can be chosen as 0.001 [13]. Since Brox optical flow algorithm requires the optical flow itself to be as smooth as possible, it is necessary to find the values of u and v to minimize the energy in Equation (2). Then, the minimizer of Equation (2) must fulfill the Euler-Lagrange equation as follows: where The first order Taylor expansion is used to remove the nonlinearity in I k+1 , then, I k+1 z ≈ I k z + I k x du k + I k y dv k I k+1 xz ≈ I k xz + I k xx du k + I k xy dv k I k+1 yz ≈ I k yz + I k xy du k + I k yy dv k (5) where u k+1 and v k+1 are the velocity components obtained in the iteration k + 1, with k a positive integer, and then represented byû andv, respectively. Furthermore, they are expressed as Equation (6), the sum of the result u k and v k obtained in the iteration k and the increments du k and dv k in the iteration k + 1.
Substitute Equation (5) into Equation (4); we have The first two items in Equation (7) are data items and the third is the smoothness term. Disassemble the data items in Equation (7) Then, the data items in Equation (7) can be simplified as: Photonics 2020, 7, 109

of 17
Let φ(x, y) = α/2 û 2 x +û 2 y +v 2 x +v 2 y , then b 1 , b 2 , a 11 and a 22 can be expressed as: Finally, the increments du k+1 and dv k+1 can be obtained by using the SOR iteration method [16]: where ω is the relaxation parameter in the SOR iteration method. a 11 , a 22 , b 1 and b 2 can be obtained after the initial values are given to u, v, du and dv. The iterative calculation using Equation (11) can be terminated until the difference of the calculation between two adjacent iterations approaches 0. Then, the optical flow fields u and v can be obtained using Equation (6). Experiment results show that Brox optical flow algorithm has the advantages of running fast, is suitable for larger displacement and is better robust to noises. Figure 1 shows the diagram of surface shape measurement using the optical flow method. A projector at point P x p , y p , z p projects a pattern onto the reference plane N, where a measured surface S can be placed. A camera located at point C(x c , y c , z c ) captures the projected pattern on the measured surface. The projection optical axis PO rays from the projector to the reference plane at an angle θ with respect to the normal of the reference plane and crosses the plane at O, which is set as the origin of the coordinate system established on the reference plane. Take the line P ⊥ O as the x-axis direction, where P ⊥ represents the foot of the perpendicular PP ⊥ on the reference plane, and the normal of the reference plane at point O as the z-axis direction. The optical axis CC ⊥ of the CCD camera is perpendicular to the reference plane, and the foot point is C ⊥ . The distance CC ⊥ is the observation distance, represented by z c . These coordinate position parameters of the projector and the camera can be calibrated using the calibration method.   Observing a point A(x, y) on the reference plane, the projection light → PA will meet the point D on the surface after placing the measured object. The height of the point D is h. In other words, the observation point A(x, y) moves to a new position B(x , y ) after the time ∆t due to the existence of the object. The displacements between two points are ∆x = x − x and ∆y = y − y. Then, the point A i (x i , y i ) moves to B i (x i + ∆x i , y i + ∆y i ) on image plane, corresponding to the point A(x, y) and B(x , y ), where ∆x i and ∆y i are the displacement in the x and y direction. The relations of the displacement between them are ∆x i = M c ∆x and ∆y i = M c ∆y, where M c is the image magnification. The optical flow formed by deformation is the velocity components at the point A i (x i , y i ), can be expressed as:

The Principle of the Surface Shape Measurement
where the time interval between two captured frames, ∆t, usually set as 1 for convenience in calculation because of no limitation on it.
In order to find the relationship between the deformation of the fringes and the height of the object surface, geometric analysis is performed as follows. First, use the coordinates of the projector and the camera to show some important lengths of the line segments in the measurement system: where x = x + ∆x = x + u∆t/M c and y = y + ∆y = y + v∆t/M c . Then, passing through point C, draw an auxiliary plane M parallel to the reference plane N. Extend the line AP to intersect the plane M at point P . Geometrically, we know that P C//AB due to point, P , C, A and B, are coplanar. On the plane P CAB, the cosines of ∠PAB and ∠CPA are shown in Equation (14) using the law of cosines: and Then, the length of the line segment CP can be expressed by the cosines of ∠PAB and ∠CPA using the sine theorem: The height at point D can be expressed as: Substitute Equations (13)-(15) into Equation (17); the expression of the height h of point D can be obtained: Usually, the foot of the CCD camera on reference plane, C ⊥ , is used as the origin of the coordinate system, and let the projection center coincide with the observation center in experiment.

Correction Principle
In the actual measurement, usually, the optical center of the projector is not at the same height as that of the camera, which results in the inconsistent measured result with that of the actual object. In this section, we propose a correction method to solve the problem in the optical flow method.
For the sake of simplicity, Figure 1 is simplified into a 2-D coordinate system. As shown in Figure 2, the optical center of the projector is at the same height as that of the camera completely. Consider two points, D and D , which are at the same height h on the surface of the measured object. When the two points are observed by the camera, the magnitudes of the displacement at the two points caused by the same height are different. Let ∆x 1 and ∆x 2 represent the displacement caused by h at point D and D , respectively. Then, we have h where d = x p − x c is the distance between the projector and the camera. It is easy to obtain that Photonics 2020, 7, x FOR PEER REVIEW 8 of 17 It can be seen from Equation (20) that the horizontal component of the optical flow u at point D is also equal to that at point D′ . However, in practice, it is difficult to make the optical center of the projector at exactly the same height as that of the camera. Once the optical center P′ and C are not on the same horizontal line, 1 x Δ will no longer be equal to 2 x Δ , resulting in a height deviation in the calculated value.
As shown in Figure 3, we can think of the projector moving from P′ to P. Then, there is a displacement A x y on the reference plane at an incident angle α with respect to the normal of the reference plane. A displacement would be introduced due to the measured surface when the point D is observed from the CCD sensor, which is represented by x Δ . From the analyses above, we know that there are no deviation errors when the projector is located at the point P′ horizontal to the CCD optical center. Therefore, the corrected displacement x′ Δ can be obtained after finding the small offset δ caused by the movement of the projector. It can be seen from Equation (20) that the horizontal component of the optical flow u at point D is also equal to that at point D . However, in practice, it is difficult to make the optical center of the projector at exactly the same height as that of the camera. Once the optical center P and C are not on the same horizontal line, ∆x 1 will no longer be equal to ∆x 2 , resulting in a height deviation in the calculated value.
As shown in Figure 3, we can think of the projector moving from P to P. Then, there is a displacement ∆p z in the vertical direction and ∆p x in the horizontal direction relative to the position P . The projection line that hits D will meet point A(x, y) on the reference plane at an incident angle α with respect to the normal of the reference plane. A displacement would be introduced due to the measured surface when the point D is observed from the CCD sensor, which is represented by ∆x. From the analyses above, we know that there are no deviation errors when the projector is located at the point P horizontal to the CCD optical center. Therefore, the corrected displacement ∆x can be obtained after finding the small offset δ caused by the movement of the projector. position P′ . The projection line that hits D will meet point ( , ) A x y on the reference plane at an incident angle α with respect to the normal of the reference plane. A displacement would be introduced due to the measured surface when the point D is observed from the CCD sensor, which is represented by x Δ . From the analyses above, we know that there are no deviation errors when the projector is located at the point P′ horizontal to the CCD optical center. Therefore, the corrected displacement x′ Δ can be obtained after finding the small offset δ caused by the movement of the projector. As can be seen from Figure 3 that As can be seen from Figure 3 that and Then, the corrected displacement can be expressed as: where ∆x = u · ∆t/M c , which is calculated from the optical flow method. The height of the point D is H after modification, is expressed as: Using Equation (24), the correction of the measurement result and the surface shape information of the object can be retrieved with high precision by using the proposed method, avoiding the problem of the tilt error.

Numerical Simulation and Analysis of Surface Shape Measurement by Optical Flow Method
The height distribution of the measured surface can be calculated by using Equation (18) and its tilt error can be corrected by using Equation (24). It can be found that there are no restrictions on projection patterns. First, we use the usual parallel projection fringe pattern for shape measurement in simulations and experiments. Then, speckle patterns are proved to be feasible in experiments.
Photonics 2020, 7, 109 9 of 17 A spherical crown of the size 40 × 40 mm simulated by MATLAB is set to be measured, as shown in Figure 4. The radius of the sphere R is 20 mm and the maximum of its height h max is 10 mm. The height of the spherical crown is expressed as

Numerical Simulation and Analysis of Surface Shape Measurement by Optical Flow Method
The height distribution of the measured surface can be calculated by using Equation (18) and its tilt error can be corrected by using Equation (24). It can be found that there are no restrictions on projection patterns. First, we use the usual parallel projection fringe pattern for shape measurement in simulations and experiments. Then, speckle patterns are proved to be feasible in experiments.
A spherical crown of the size 40 × 40 mm simulated by MATLAB is set to be measured, as shown in Figure 4. The radius of the sphere R is 20 mm and the maximum of its height max h is 10 mm. The height of the spherical crown is expressed as The system shown in Figure 1 is employed to measure the shape of the spherical crown. The imaging distance of the camera c z and the projection distance p z are 2000 mm, respectively. The distance between projection and the camera d is 60 mm and the image magnification c M is −12.8 pixel/mm. The optical center of the projector can be considered to be approximately at the same height as that of the camera due to the small projection angle. Before placing the object, the light intensity of the projection fringes parallel to the y-axis direction on the reference plane can be expressed as where a is the background light intensity, b is the fringe contrast, x f and y f are the fringe frequencies at ( , ) x y . The image captured by the CCD camera at time t is expressed as Figure 4. The spherical crown to be measured.
The system shown in Figure 1 is employed to measure the shape of the spherical crown. The imaging distance of the camera z c and the projection distance z p are 2000 mm, respectively. The distance between projection and the camera d is 60 mm and the image magnification M c is −12.8 pixel/mm. The optical center of the projector can be considered to be approximately at the same height as that of the camera due to the small projection angle. Before placing the object, the light intensity of the projection fringes parallel to the y-axis direction on the reference plane can be expressed as where a is the background light intensity, b is the fringe contrast, f x and f y are the fringe frequencies at (x, y). The image captured by the CCD camera at time t is expressed as where f ix = f x /M c and f iy = f y /M c are the fringe frequencies of the recorded image, The subscript i represents the physical parameters on the image plane. After placing the object, the light intensity of the modulated fringe image captured at time t + ∆t is According to Equations (27) and (28), the captured fringe patterns before and after deformation are of size 512 × 512 pixels-shown in Figure 5a,b-respectively, where a = 128, b = 60, f ix = 0.4 mm −1 , f iy = 0. The fringe deformation is small due to the small distance d between the projector and CCD, and the maximum of deformation in the deformed pattern is 4 pixels.
According to Equations (27) and (28), the captured fringe patterns before and after deformation are of size 512 × 512 pixels-shown in Figure 5a By using the two images shown in Figure 5, the Brox optical flow algorithm is employed to estimate the optical flow field. In the calculation of the optical flow, the weight factor γ is 10, and the regularization parameter α is 100, which can make the algorithm robust to noise, suggested by Brox [13]. Then, the height distribution of the ball crown can be obtained using Equation (18). The By using the two images shown in Figure 5, the Brox optical flow algorithm is employed to estimate the optical flow field. In the calculation of the optical flow, the weight factor γ is 10, and the regularization parameter α is 100, which can make the algorithm robust to noise, suggested by Brox [13]. Then, the height distribution of the ball crown can be obtained using Equation (18). The result is shown in Figure 6a. Using two fringe patterns to obtain the height distribution in the optical flow method, it is similar to that of the FTP method. Therefore, the height distribution is recalculated by using the FTP method for comparison. The cross section data at y = 0 mm in x direction obtained by the optical flow method and the FTP method are compared with those of the true value, as shown in Figure 6b. It can be seen that both results of the two methods are close to the real value, indicating that the optical flow method has high precision in the surface shape measurement as good as that of the FTP method under the same condition. By using the two images shown in Figure 5, the Brox optical flow algorithm is employed to estimate the optical flow field. In the calculation of the optical flow, the weight factor γ is 10, and the regularization parameter α is 100, which can make the algorithm robust to noise, suggested by Brox [13]. Then, the height distribution of the ball crown can be obtained using Equation (18). The result is shown in Figure 6a. Using two fringe patterns to obtain the height distribution in the optical flow method, it is similar to that of the FTP method. Therefore, the height distribution is recalculated by using the FTP method for comparison. The cross section data at y = 0 mm in x direction obtained by the optical flow method and the FTP method are compared with those of the true value, as shown in Figure 6b. It can be seen that both results of the two methods are close to the real value, indicating that the optical flow method has high precision in the surface shape measurement as good as that of the FTP method under the same condition. The random noise has a great influence on the measurement results. Then，the fringe patterns before and after deformation are polluted by the Gaussian noises with the SNR of 10 and 20 dB, respectively, to simulate the influence of the environmental noises and the thermal noises of the The random noise has a great influence on the measurement results. Then, the fringe patterns before and after deformation are polluted by the Gaussian noises with the SNR of 10 and 20 dB, respectively, to simulate the influence of the environmental noises and the thermal noises of the camera. By using the noised fringe patterns, the height distributions of the ball crown are obtained. Then, the distributions of the absolute error are obtained modulo subtracting the cross section data of the calculated results from the true value at y = 0 mm in x direction, as shown in Figure 7. It can be seen that the absolute errors are less than 0.2 mm compared with the noiseless pattern when the noised pattern with SNR is of 10 and 20 dB, respectively. The root mean square (RMS) errors increases with the noise and its maximum value is less than 0.15 mm. It shows that the Brox optical flow algorithm has good robustness to noises.
Photonics 2020, 7, x FOR PEER REVIEW 11 of 17 camera. By using the noised fringe patterns, the height distributions of the ball crown are obtained. Then, the distributions of the absolute error are obtained modulo subtracting the cross section data of the calculated results from the true value at y = 0 mm in x direction, as shown in Figure 7. It can be seen that the absolute errors are less than 0.2 mm compared with the noiseless pattern when the noised pattern with SNR is of 10 and 20 dB, respectively. The root mean square (RMS) errors increases with the noise and its maximum value is less than 0.15 mm. It shows that the Brox optical flow algorithm has good robustness to noises. in the actual experiment, these parameters need to be calibrated by optical methods, which may cause errors. In order to explain the impact of calibration error on the calculation results, a incremental 5 mm is firstly added to the observation distance c z and the projection distance p z , respectively, as In the simulations above, the parameters in the measurement system such as z p , z c and d are constants, which are set as z p = 2000 mm,z c = 2000 mm and d = 60 mm, respectively. However, in the actual experiment, these parameters need to be calibrated by optical methods, which may cause errors. In order to explain the impact of calibration error on the calculation results, a incremental 5 mm is firstly added to the observation distance z c and the projection distance z p , respectively, as the calibration error when d = 60 mm. Then, increase d by 5 mm when z p and z c are both 2000 mm. The absolute errors of 5 mm increments are compared with its original distance, as shown in Figure 8, respectively. It can be seen that the increases of 5 mm in the observation distance and projection distance have little effect on the measurement results. Although the change in d has an obvious effect on the error distribution compared with the first two parameters, the absolute error is still within a small range. So, we can ignore the error caused by the system calibration in the experiment. Furthermore, the parameter d is closely related to the amount of deformation of the projected pattern, which can affect the accuracy of the optical flow algorithm. Therefore, we should make d small enough in experiments.  mm. The absolute errors of 5 mm increments are compared with its original distance, as shown in Figure 8, respectively. It can be seen that the increases of 5 mm in the observation distance and projection distance have little effect on the measurement results. Although the change in d has an obvious effect on the error distribution compared with the first two parameters, the absolute error is still within a small range. So, we can ignore the error caused by the system calibration in the experiment. Furthermore, the parameter d is closely related to the amount of deformation of the projected pattern, which can affect the accuracy of the optical flow algorithm. Therefore, we should make d small enough in experiments.

Error Correction Simulation
In Section 3.1, the situations are completed when the projector is at the same height as that of the camera. In this section, we consider the case that the observation distance is not equal to the projection distance. When the projection angle θ = π/100, the observation distance z c and the projection distance L p are set as 2000 and 1800 mm, respectively, the move component of the projector ∆p y in vertical direction is about −200 mm. Then, a tilt error occurs due to the deviation of the projector. As shown in Figure 9a, the cross section data of the calculated height distribution is deviated from the true value at y = 0 mm in x direction. The tilt error can be corrected using Equation (24), as shown in Figure 9b. After correction, the absolute error between the calculated value and the true value can be greatly reduced to 0.3 mm, as shown in Figure 9c, indicating that the proposed correction method is feasible.

Error Correction Simulation
In Section 3.1, the situations are completed when the projector is at the same height as that of the camera. In this section, we consider the case that the observation distance is not equal to the projection distance. When the projection angle / 100 θ π = , the observation distance c z and the projection distance p L are set as 2000 and 1800 mm, respectively, the move component of the projector vertical direction is about −200 mm. Then, a tilt error occurs due to the deviation of the projector. As shown in Figure 9a, the cross section data of the calculated height distribution is deviated from the true value at y = 0 mm in x direction. The tilt error can be corrected using Equation (24), as shown in Figure  9b. After correction, the absolute error between the calculated value and the true value can be greatly reduced to 0.3 mm, as shown in Figure 9c, indicating that the proposed correction method is feasible.

Sensitivity Analysis
The sensitivity of a system can be intuitively understood as the change of the output caused by a certain amount of input change. Based on the triangulation method, the optical setup of the proposed method is just like that of the PMP method. Then, the sensitivity of the method can be

Sensitivity Analysis
The sensitivity of a system can be intuitively understood as the change of the output caused by a certain amount of input change. Based on the triangulation method, the optical setup of the proposed method is just like that of the PMP method. Then, the sensitivity of the method can be defined as We can use Figure 2 to analyze the sensitivity of this method. According to Equation (17), the deformation of the fringe on image plane caused by h is Then, Equation (29) can be approximately expressed as S = M c · d/z c when the measured height is far less than z c . We can obtain that the sensitivity of the method is about 0.4 pixel/mm at the maximum height of the ball crown. The proposed method requires the incidence angle small enough to ensure that the deformation of the fringes can be measured by the optical flow method. Small angle projection can avoid shadows of the measured object, but it reduces the sensitivity of measurement. According to the reported resolution of 0.01 pixel in the horizontal direction in the optical flow method [10], the resolution in the direction of height is about 0.02 mm. This resolution is sufficient for most measurements.

An Experiment on a Smooth Measuring Object
The measurement system as shown in Figure 1 is utilized to measure the height distribution of the specimen, as shown in Figure 12. The maximum height of the mask is 63.20 mm. The projected pattern used in the proposed optical flow method is not limited to the fringe pattern. Usually, a parallel fringe pattern is utilized to measure the surface shape in current techniques including the FTP method. Therefore, the fringe pattern is firstly used for projection in this section to facilitate comparison with the FTP method. According to the discussion above, the deformation of the deformed fringes should be small to meet the brightness constant of optical flow. Therefore, the projection angle should be small in the setup. Then, the measurement follows the following steps: • Calibrating the measurement system. In order to make the effect of the correction method obvious, we set the projection distance and observation distance with large distance. Different from the optical setup parameter estimation method [17], the optical center positions of the projector and camera are calibrated by using Zhang's calibration method [18,19]. After calibration, the distance from the projector to the reference plane is 1975.40 mm and that of the CCD sensor is 1922.80 mm. The horizontal distance between the CCD sensor and the projector is 84.50 mm. The magnification of the image is 512/220 pixel/mm. The calibration process will take about 10 min, but the following steps can be performed multiple times as long as the calibration is completed once. • Capturing two images. The two images before and after placing the object are recorded by an ordinary CCD sensor with the sensitive area of 768 × 576 pixels at 8-bit resolution. The captured images are shown in Figure 10. We estimate the noise level of the image by using the method proposed by Chen et al. [20]. The mean noise level of Figure 10b is 1.41 dB.

•
Calculating the optical flow and height distribution. After calculating the optical flow between the two images by using the Brox method, the height distribution of the specimen can be obtained according to Equation (18)-shown in Figure 11. This step will take 6 to 10 s depending on the image size and the parameters of Brox algorithm.  It should be noted that the location of the projector is 52.60 mm farther than that of the CCD sensor to the reference plane. This would introduce a tilt error in the measurement result. The tilt error can be corrected according to Equation (24). The corrected result is shown in Figure 13a. In order to show the effect of the correction, the cross section data of the corrected result at y=-20 mm in x direction (passing through the hollow area of the object) are compared with those of the uncorrected result, as shown in Figure 13b. To compare with the result before correction, the correction effect is obvious and satisfactory. First, the maximum of the height is 62.19 mm after correction. At the maximum height, the absolute error of the corrected measurement results is 1.01 mm and the relative error is less than 2%. Second, the height distribution becomes left-right symmetric after correction. The tilt error occurs in calculated height distribution before correction has been greatly reduced.
As described in Section 3.1, the proposed method has no restrictions on projection patterns, which is illustrated by an experiment with projected speckle patterns. Using the measurement system shown in Figure 1 and the same parameters as the experiment in Section 4.1, the height distributions of the specimen are obtained using Equation (18) following the experimental steps described above. Figure 14 shows the height distribution of the specimen using the projected speckle pattern. parallel fringe pattern is utilized to measure the surface shape in current techniques including the FTP method. Therefore, the fringe pattern is firstly used for projection in this section to facilitate comparison with the FTP method. According to the discussion above, the deformation of the deformed fringes should be small to meet the brightness constant of optical flow. Therefore, the projection angle should be small in the setup. Then, the measurement follows the following steps: • Calibrating the measurement system. In order to make the effect of the correction method obvious, we set the projection distance and observation distance with large distance. Different from the optical setup parameter estimation method [17], the optical center positions of the projector and camera are calibrated by using Zhang's calibration method [18,19]. After calibration, the distance from the projector to the reference plane is 1975.40 mm and that of the CCD sensor is 1922.80 mm. The horizontal distance between the CCD sensor and the projector is 84.50 mm. The magnification of the image is 512/220 pixel/mm. The calibration process will take about 10 minutes, but the following steps can be performed multiple times as long as the calibration is completed once. • Capturing two images. The two images before and after placing the object are recorded by an ordinary CCD sensor with the sensitive area of 768 × 576 pixels at 8-bit resolution. The captured images are shown in Figure 11. We estimate the noise level of the image by using the method proposed by Chen et al. [20]. The mean noise level of Figure 11b is 1.41 dB.

•
Calculating the optical flow and height distribution. After calculating the optical flow between the two images by using the Brox method, the height distribution of the specimen can be obtained according to Equation (18)-shown in Figure 12. This step will take 6 to 10 seconds depending on the image size and the parameters of Brox algorithm.  It should be noted that the location of the projector is 52.60 mm farther than that of the CCD sensor to the reference plane. This would introduce a tilt error in the measurement result. The tilt error can be corrected according to Equation (24). The corrected result is shown in Figure 13a. It should be noted that the location of the projector is 52.60 mm farther than that of the CCD sensor to the reference plane. This would introduce a tilt error in the measurement result. The tilt error can be corrected according to Equation (24). The corrected result is shown in Figure 13a. In order to show the effect of the correction, the cross section data of the corrected result at y=-20 mm in x direction (passing through the hollow area of the object) are compared with those of the uncorrected result, as shown in Figure 13b. To compare with the result before correction, the correction effect is obvious and satisfactory. First, the maximum of the height is 62.19 mm after correction. At the maximum height, the absolute error of the corrected measurement results is 1.01 mm and the relative error is less than 2%. Second, the height distribution becomes left-right In order to show the effect of the correction, the cross section data of the corrected result at y=−20 mm in x direction (passing through the hollow area of the object) are compared with those of the uncorrected result, as shown in Figure 13b. To compare with the result before correction, the correction effect is obvious and satisfactory. First, the maximum of the height is 62.19 mm after correction. At the maximum height, the absolute error of the corrected measurement results is 1.01 mm and the relative error is less than 2%. Second, the height distribution becomes left-right symmetric after correction. The tilt error occurs in calculated height distribution before correction has been greatly reduced.
As described in Section 3.1, the proposed method has no restrictions on projection patterns, which is illustrated by an experiment with projected speckle patterns. Using the measurement system shown in Figure 1 and the same parameters as the experiment in Section 4.1, the height distributions of the specimen are obtained using Equation (18) following the experimental steps described above. Figure 14 shows the height distribution of the specimen using the projected speckle pattern. In order to show the effect of the correction, the cross section data of the corrected result at y=-20 mm in x direction (passing through the hollow area of the object) are compared with those of the uncorrected result, as shown in Figure 13b. To compare with the result before correction, the correction effect is obvious and satisfactory. First, the maximum of the height is 62.19 mm after correction. At the maximum height, the absolute error of the corrected measurement results is 1.01 mm and the relative error is less than 2%. Second, the height distribution becomes left-right symmetric after correction. The tilt error occurs in calculated height distribution before correction has been greatly reduced.
As described in Section 3.1, the proposed method has no restrictions on projection patterns, which is illustrated by an experiment with projected speckle patterns. Using the measurement system shown in Figure 1 and the same parameters as the experiment in Section 4.1, the height distributions of the specimen are obtained using Equation (18) following the experimental steps described above. Figure 14 shows the height distribution of the specimen using the projected speckle pattern.  The speckle pattern is used as the projecting pattern (a) before deformation, (b) after deformation and (c) the result. The Brox method is slightly similar to the FTP method in the calculation of using the fringe patterns before and after deformation. Therefore, the height distribution of the specimen is recalculated by the FTP method. After transforming the two fringe patterns into their frequency domain using the fast Fourier transform algorithm, calculating the carrier frequency, selecting one of the spectra on the frequency axis by a window manually and translating it, inverse Fourier transform and phase unwrapping are necessary to obtain the phase distribution of the measured surface. Then, the transformation of phase-to-height is required in order to obtain the height distribution. After completing the operations above, the height distribution of the specimen can be obtained-shown in Figure 15a-from which the cross section data at y = −20 mm in x direction are selected to compare with that of the corrected Brox method. The comparison of them is shown in Figure 15b. It can be found that the result of the corrected Brox method is more accurate than that of the FTP method. The Brox method is slightly similar to the FTP method in the calculation of using the fringe patterns before and after deformation. Therefore, the height distribution of the specimen is recalculated by the FTP method. After transforming the two fringe patterns into their frequency domain using the fast Fourier transform algorithm, calculating the carrier frequency, selecting one of the spectra on the frequency axis by a window manually and translating it, inverse Fourier transform and phase unwrapping are necessary to obtain the phase distribution of the measured surface. Then, the transformation of phase-to-height is required in order to obtain the height distribution. After completing the operations above, the height distribution of the specimen can be obtained-shown in Figure 15a-from which the cross section data at y = −20 mm in x direction are selected to compare with that of the corrected Brox method. The comparison of them is shown in Figure 15b. It can be found that the result of the corrected Brox method is more accurate than that of the FTP method.

An Experiment on a Structured Object
In Section 3.1, we measure an object with a smooth surface. To illustrate the feasibility of the proposed approach, a packaging box of an instrument is measured. The packaging box is of structured surfaces, as shown in Figure 16. Its maximum height is 18.20 mm. The mean noise level of

An Experiment on a Structured Object
In Section 3.1, we measure an object with a smooth surface. To illustrate the feasibility of the proposed approach, a packaging box of an instrument is measured. The packaging box is of structured surfaces, as shown in Figure 16. Its maximum height is 18.20 mm. The mean noise level of the captured image is 2.86 dB, also estimated by Chen's method. The corrected measurement result is shown in Figure 17, where the maximum of the measured height is 18.25 mm. The absolute error and relative error at the point are 0.05 mm and 0.3%, respectively. The experimental result show that the proposed method is suitable for 3-D reconstruction of objects with structural surface.

An Experiment on a Structured Object
In Section 3.1, we measure an object with a smooth surface. To illustrate the feasibility of the proposed approach, a packaging box of an instrument is measured. The packaging box is of structured surfaces, as shown in Figure 16. Its maximum height is 18.20 mm. The mean noise level of the captured image is 2.86 dB, also estimated by Chen's method. The corrected measurement result is shown in Figure 17, where the maximum of the measured height is 18.25 mm. The absolute error and relative error at the point are 0.05 mm and 0.3%, respectively. The experimental result show that the proposed method is suitable for 3-D reconstruction of objects with structural surface.
(a) (b) Figure 16. Images of the experiment on a structured object (a) before deformation, (b) after deformation. Although the experimental result is satisfactory, the accuracy of it may not be as high as that of PMP method. However, the advantages of the proposed method are obvious and potential. Firstly, the measurement time is much shorter than that of the PMP method because only two images are required. Secondly, the height distribution is obtained directly without phase calculation like the PMP method. Finally, a more diversified pattern can be used for projection in the proposed method, such as speckle pattern, which is difficult for data processing in the PMP method. Moreover, the proposed method based on the optical flow is more suitable for dynamic measurement.

Conclusions
In this paper, a new technique for measuring the surface shape of an object based on the Brox optical flow method is presented. The measurement system is simple with one projector and a CCD sensor. Because of the small projection angle, the shadow problem is avoided. The proposed method has no restrictions on projection patterns. Due to the tilt error that exists in the measurement results, an error correction method for the optical flow method is proposed, by which the height distribution can be accurately measured. Simulations and experiments are completed to demonstrate the characteristics of the proposed method. The result shows that the Brox optical flow algorithm has good robustness to noises. It also shows that the measurement results are not sensitive to the deviation of projection distance and observation distance. The deviation of 5mm of the projection Although the experimental result is satisfactory, the accuracy of it may not be as high as that of PMP method. However, the advantages of the proposed method are obvious and potential. Firstly, the measurement time is much shorter than that of the PMP method because only two images are required. Secondly, the height distribution is obtained directly without phase calculation like the PMP method. Finally, a more diversified pattern can be used for projection in the proposed method, such as speckle pattern, which is difficult for data processing in the PMP method. Moreover, the proposed method based on the optical flow is more suitable for dynamic measurement.

Conclusions
In this paper, a new technique for measuring the surface shape of an object based on the Brox optical flow method is presented. The measurement system is simple with one projector and a CCD sensor. Because of the small projection angle, the shadow problem is avoided. The proposed method has no restrictions on projection patterns. Due to the tilt error that exists in the measurement results, an error correction method for the optical flow method is proposed, by which the height distribution can be accurately measured. Simulations and experiments are completed to demonstrate