# Detecting Distance between Surfaces of Large Transparent Material Based on Low-Cost TOF Sensor and Deep Convolutional Neural Network

Authors: Rong Zou; Yu Zhang; Junlan Gu; Jin Chen
Journal: Advances in Materials Science and Engineering
 (2021)

---

## Abstract

Detecting distance between surfaces of transparent materials with large area and thickness has always been a difficult problem in the field of industry. In this paper, a method based on low-cost TOF continuous-wave modulation and deep convolutional neural network technology is proposed. The distance detection between transparent material surfaces is converted to the problem of solving the intersection of the optical path and the transparent material’s front and rear surfaces. On this basis, the Gray code encoding and decoding operations are combined to achieve distance detection between surfaces. The problem of holes and detail loss of depth maps generated by low-resolution TOF depth sensors have been also effectively solved. The entire system is simple and can achieve thickness detection on the full surface area. Besides, it can detect large transparent materials with a thickness of over 30 mm, which far exceeds the existing optical thickness detection system for transparent materials.


---

## Body

## 1. Introduction

Distance detection between surfaces of transparent materials has always been a research hotspot in the field of industry. The traditional contact distance detection method between surfaces is the simplest and lowest cost method, such as the use of vernier calipers or micrometers. The disadvantage is that it can only detect the single surface point near the edge of the surface. It needs to perform manually and cannot automate. So, it is inefficient and gradually eliminated.Currently, noncontact distance detection methods between surfaces are widely used, which can be roughly divided into optical and nonoptical methods. The typical capacitance method [1–3] is a nonoptical distance detection method between surfaces. This method is based on the principle that the transparent material causes the capacitance change to detect the distance between surfaces of the transparent material. The entire system is simple, but it is extremely susceptible to space electromagnetic interference and changes in the distributed capacitance between lines. The fluorescent immersion method [4–6] is an indirect optical detection method. The transparent material is immersed in a special liquid. The liquid will emit fluorescence after being irradiated by a laser. Since the transparent material does not emit light, a sharp boundary can be obtained. The optical image is recorded by a camera. The distance between the surfaces of the transparent material can be obtained after the calculation and processing. This method has a complicated system structure and requires the use of fluorescent liquid to cause inconvenience to the user.Direct optical methods include grating spectroscopy and light triangulation. Grating spectroscopy is designed based on the principle of grating spectroscopy [7]. The system uses white light illumination. The light obtained after being reflected by the transparent material is decomposed by the concave grating. The decomposed spectrum is received by the sensor. The data is sent to the computer for spectral analysis. The distance between the surfaces of the transparent material is obtained. The drawback of this method is that the distance detection system is very difficult to adjust and correct. The optical triangulation method [8–11] uses the principle of the difference in displacement between the upper and lower surfaces of the transparent material. The system is simple, convenient, and effective. So, it is the most used method at present. Nevertheless, this method is easily affected by stray light. At least for now, there is a common shortcoming of these existing methods for detecting the distance between surfaces of the transparent material; that is, they can only measure a very limited small area at a time [12]. It is impossible to give an objective evaluation of the distance change between the entire surfaces of the transparent material. Besides, the thickness detected by these methods is limited, and the maximum cannot exceed 15 mm.To develop a method that can detect the distance between the entire surfaces of the large transparent material at a time, we also refer to a variety of transparent object surface reconstruction methods. Murase [13] provided a new idea for recovering shapes from pattern distortions for transparent fluid materials. The geometric information of transparent materials is speculated from the distortion of known or unknown calibration patterns caused by light refraction. This method is mainly aimed at the problem of water surface shape reconstruction. Morris and Kutulakos [14] considered the water surface reconstruction with time on this basis. His method can not only obtain the refractive index but also accurately estimate the depth and normal vector of each pixel. It is not dependent on the surface mean and is highly robust. Kutulakos and Steger [15] analyzed the possibility of using triangulation to realize the three-dimensional reconstruction of the surface of transparent materials. They proposed a light direct measurement method. But the common feature of the above measurement methods is that passive visual sensors are used to passively capture light on the surface of transparent materials.In recent years, active time-of-flight (TOF) depth sensors are being widely used in the field of 3D digital modeling with the advantages of high efficiency and wide adaptability. Therefore, a small number of researchers also conducted some preliminary studies on the active TOF sensor used in the surface reconstruction of transparent materials [16]. The modulated light emitted by the TOF depth sensor travels in a transparent material at a slower speed than the air, so the so-called distortion phenomenon occurs. This distortion phenomenon carries relevant thickness information. This provides a new idea for our distance detection method between entire surfaces of the large transparent material. However, these current exploratory methods have many shortcomings, especially the hole problem in the depth map generation process, which has a huge impact on the distance detection between surfaces of the transparent material. It should be noted that, in order to reflect that our method can realize the thickness detection of the entire surface area of the object, we use the phrase “distance between surfaces” to replace the commonly referred term “thickness” in this article.Here, we propose a novel method of optics. This method uses low-cost TOF sensors and deep convolutional neural network technology to achieve distance detection between the surfaces of the large transparent material. It can effectively reduce the cost of the system. The main idea is to transform the distance detection between transparent material surfaces into front and rear surface reconstruction problems. We further demonstrated that surface reconstruction of the transparent material can also be converted to the problem of searching for the intersection of the light path and the front and back surfaces of the transparent object and its surface normal. Combining a series of Gray code patterns, the entire detection system is simple and easy to implement. Another contribution of this paper is the introduction of deep convolutional neural networks into the field of active vision. Thereby, the performance of the low-cost TOF sensor is used to the limit. Our method can detect the large transparent material with a thickness of over 30 mm.


## 2. Methodologies

TOF depth sensors are divided into a single-photon counting measurement method and a continuous-wave modulation measurement method according to the form of emitted light waves. In the continuous-wave modulation method, a sinusoidal signal is invoked as the signal of the optical transmitter. Depth measurement is achieved by calculating the phase difference between the received and emitted waves, as shown in Figure1. It is easy to implement at a low cost [17]. The basic measurement equation is expressed as(1)Depth=c2⋅t=c2⋅Δϕ2πf,where Depth represents the distance between the camera and the object, c is the speed of light, t represents the travel time of the round-trip light, Δϕ shows the phase difference between the returned signal and the received signal, and f is the natural frequency.Figure 1
The continuous-wave modulation measurement method of TOF.The principle of distance detection between the surfaces of the transparent material is shown in Figure2. O is the coordinates of the optical center of the sensor. A1 and A2 represent the points on the front and rear surfaces of the transparent material. B1 and B2 represent a set of distorted three-dimensional points when the reference plate is moved back and forth corresponding to the image pixels. The direction of the light emitted by the TOF depth sensor is OA1⟶. When the reference board is placed in the first reference position, the TOF depth sensor is used to collect infrared images and depth data of the surface position of the transparent material. It mainly includes two sets of data without the transparent material and transparent material. Based on these two sets of data, the distorted three-dimensional point of the first position OB1⟶ can be obtained. The current position of the reference board is also recorded. By moving the platform, the reference board is moved to the second position. Repeating the detection step of the previous position, we get the distorted three-dimensional point OB2⟶ in the second position. Similarly, the position and moving distance of the reference board are recorded at this time. The difference between the distorted three-dimensional points of the two positions can be obtained as the reference light direction B1B2⟶. A series of Gray code patterns are used in the reference board [18], as shown in Figure 3. According to the sensor light direction OA1⟶, the reference light direction B1B2⟶, and the corresponding depth data, the front and back surface points of the transparent material can be obtained by using related algorithms. Finally, the distance between the surfaces of the transparent material is obtained. It should be noted that V1⟶ and V2⟶ represent the sensor light direction and the reference light direction, which need to be converted into their unit vectors to participate in the calculation.Figure 2
Detecting distance principle between surfaces of the transparent material.Figure 3
Gray code sequence.


### 2.1. Estimation of Transparent Material Surface Points

Figure4 shows Snell’s normal law in refracted light. At a point i on the rear surface, Snell’s norm is defined as(2)SNi⟶=V2⟶−nA1A2⟶V2⟶−nA1A2⟶=B1B2⟶−nA1A2⟶B1B2⟶−nA1A2⟶,where SNi⟶ is the Snell normal vector at point i on the rear surface, A1A2⟶ represents the space vector at the intersection of the refracted light path and the front and rear surfaces of the transparent material, and n is the refractive index of the transparent material.Figure 4
Normal diagram of a surface point of the transparent material. (a) Normal distribution at a point on the front surface. (b) Normal distribution at a point on the rear surface.
(a)(b)The surface normal at the point is expressed as(3)Ni⟶=∂OB1⟶−A2B1⟶V2⟶/∂u×∂OB1⟶−A2B1⟶V2⟶/∂v∂OB1⟶−A2B1⟶V2⟶/∂u×∂OB1⟶−A2B1⟶V2⟶/∂v,where Ni⟶ is the surface normal at the point i, A2B1⟶ is the distance from the point on the back surface of the transparent material to the corresponding point on the first position reference plate, u, v are the image horizontal axis and vertical axis, and ∂ is partial differential calculation.From equations (2) and (3), the two normals should coincide; that is, the summation term has a minimum value in the following equation:(4)A2B1⟶=argminA2B1⟶∑i∈ISNi⟶−Ni⟶22.


### 2.2. Measurement Model Based on TOF Continuous-Wave Modulation

There are multiple variables in expressions ofSNi⟶ and Ni⟶. Combined with the inherent model of the TOF continuous-wave modulation principle, we get(5)D=OA1⟶+nA1A2⟶+A2B1⟶,where D represents the actual distance between the sensor lens and the reference plate, which are directly read by the depth sensor. OA1⟶, A1A2⟶,A2B1⟶ are three unknowns in equation (5). According to the calculation rule of the vector, the relationship between the three unknowns can be obtained:(6)OA1⟶=OA1⟶V1⟶,OB1⟶=OA2⟶+A2B1⟶B1B2⟶,=OA2⟶+A2B1⟶V2⟶,A1A2⟶=OA2⟶−OA1⟶.Substituting equation (6) into equation (5), we can get(7)OA1⟶=−D−A2B1⟶−n2OB1⟶T∗V1⟶±D−A2B1⟶−n2OB1⟶T∗V1⟶2−n2−1n2OB1⟶2−D−A2B1⟶2n2−1.Therefore, after putting equations (6) and (7) in equation (5), there is only one unknown A2B1⟶. According to equation (4), the back surface depth data corresponding to each pixel of the rear surface can be estimated. Combined with equation (6), the surface points of the front and back of the transparent material can be estimated:(8)OA2⟶=OB1−⟶A2B1⟶V2⟶,OA1⟶=OA1⟶V1⟶.So, the normal map can be resolved by equation (2) or equation (3). The depth data used in equation (4) only comes from the depth value directly read by the depth sensor. In practice, as the depth sensor usage time becomes longer during the experiment, the noise also increases [19]. We propose using a regularization method to reduce noise interference. A regularization term is introduced for each pixel. di is the estimated noise-free TOF optical length and di′ is the actual depth value reads. The noise suppression optimization equation is given by(9)A2B1⟶=argminA2B1⟶∑i∈ISNi⟶−Ni⟶22+λ∑i′∈Nidi−di′22.The above equation can be interpreted as an estimate of the shape of the rear surface becauseA2B1⟶ corresponds to the depth data of the rear surface. To avoid calculating the second derivative with high computational complexity, the L-BFGS method [20] is utilized here. It only uses approximate Hessian matrices instead of calculating them specifically.


### 2.3. Patching Holes in Low-Resolution Depth Maps

In the above measurement model, the integrity of the transparent material depth data acquisition is critical. The low-cost TOF depth sensor has a lower resolution. Besides, the depth map obtained is usually affected by complex factors so that holes often appear at the edges and occlusions of the object. It seriously affects subsequent processing and information extraction [21]. Figure 5 is an example of holes in a depth map, where too bright (Gray value of 255) and too dark (Gray value of 0) are the positions of holes. Generally, the area where the transparent material is located is prone to holes, including small and large areas. The depth value represented by the hole position is not valid. In other words, the lack of depth data occurs. Patching the holes in the depth map is an important part of using low-cost TOF depth sensors to detect the distance between the surfaces of the transparent material.Figure 5
Examples of holes in the depth map. The object in the red box is transparent materials.A hole patching method based on a convolutional neural network is proposed. First, the depth map is generated and the hole position is detected to generate a hole mask map. Then, the hole mask map and original depth map are fed into the deep convolutional neural network to achieve unsupervised hole patching.Untrained deep convolutional neural networks are used, in which the weights are randomly initialized. In the autonomous unsupervised learning process, the network weight parameters needed for depth map patching are generated. That is, based on the given damaged depth map and task-dependent observation model, a randomly initialized convolutional neural network is given. The model parameters are provided by iterations to make it close to the maximum likelihood value. In this paper, the depth map patching task is represented as a problem of energy minimization, given by(10)x∗=minxEx;x0+Rx,where x,x0 are the depth map generated by the neural network and the original depth map with holes. Ex;x0 depends on the specific application scenario, which mainly compares the difference between the generated data and the original data. In equation (10), it is necessary to find the value of x that minimizes Ex;x0 and as the output x∗ of the final network. Rx is a priori knowledge of the depth map, which is often captured by training a convolutional neural network with a large sample. But here, the implicit prior information captured by the convolutional neural network is used to replace Rx. The convolutional neural network learns from the input randomly coded image to the mapping of the original depth map with holes. x∗ is reconstructed from the optimal solution θ∗ obtained by learning. So, equation (10) becomes(11)x∗=fθ∗z,θ∗=argminθEfθz;x0,where θ is the network parameters and θ∗ is the optimal solution of the parameters obtained by Adam gradient descent algorithm training based on the random initialization network. The random vector z is the input code of the network. Once the optimal parameters are obtained, the input z can be calculated to obtain the optimal x. Therefore, the idea of the algorithm is essentially the process of searching for the optimal θ in the feasible space. Use the gradient descent [22] method to randomly initialize the parameters to obtain the (local) minimizer θ.Figure6 is the network structure of the depth map patching algorithm. The overall structure is an Encode-Decode network structure. Input random code z, original depth maps containing holes, and hole mask maps and then let the convolutional neural network autonomously learn the mapping from original pixel values of the input randomly coded z to the original depth map containing the holes according to the areas without holes in the hole mask map. The model network is formed by the cascade of encoding compression (encoder) and decoding reconstruction (decoder). The sampling unit of each layer includes a convolution layer (convolution), a batch normalization layer (BN, batch normalization) [23], and the nonlinear activation function layer (LReLU, Leaky ReLU) [24]. As shown in Figure 6, the downsampling unit uses a convolution layer and the upsampling unit uses nearest-neighbor interpolation convolution. We use the “Meshgrid” image as the input code. Subsequent experiments show that this type of input will increase the smoothness. It is useful for hole patching.Figure 6
The network structure of the depth map patching algorithm.The number of filters in the downsampling unit and the upsampling unit is 16, 32, 64, 128, 128, and 128. The kernel size is 3 and 5. These are all fixed values. After each convolutional layer, there is a BN layer to normalize the data to improve the details of image restoration. In the convolutional neural network, it is necessary to utilize the activation function as a nonlinear transformation. Complex mapping relationships can be learned. In the algorithm, there is a Leaky ReLU activation function after each BN layer, given by(12)LeakyReLUxi=xi,xi≥0,axi,xi<0.


## 2.1. Estimation of Transparent Material Surface Points

Figure4 shows Snell’s normal law in refracted light. At a point i on the rear surface, Snell’s norm is defined as(2)SNi⟶=V2⟶−nA1A2⟶V2⟶−nA1A2⟶=B1B2⟶−nA1A2⟶B1B2⟶−nA1A2⟶,where SNi⟶ is the Snell normal vector at point i on the rear surface, A1A2⟶ represents the space vector at the intersection of the refracted light path and the front and rear surfaces of the transparent material, and n is the refractive index of the transparent material.Figure 4
Normal diagram of a surface point of the transparent material. (a) Normal distribution at a point on the front surface. (b) Normal distribution at a point on the rear surface.
(a)(b)The surface normal at the point is expressed as(3)Ni⟶=∂OB1⟶−A2B1⟶V2⟶/∂u×∂OB1⟶−A2B1⟶V2⟶/∂v∂OB1⟶−A2B1⟶V2⟶/∂u×∂OB1⟶−A2B1⟶V2⟶/∂v,where Ni⟶ is the surface normal at the point i, A2B1⟶ is the distance from the point on the back surface of the transparent material to the corresponding point on the first position reference plate, u, v are the image horizontal axis and vertical axis, and ∂ is partial differential calculation.From equations (2) and (3), the two normals should coincide; that is, the summation term has a minimum value in the following equation:(4)A2B1⟶=argminA2B1⟶∑i∈ISNi⟶−Ni⟶22.


## 2.2. Measurement Model Based on TOF Continuous-Wave Modulation

There are multiple variables in expressions ofSNi⟶ and Ni⟶. Combined with the inherent model of the TOF continuous-wave modulation principle, we get(5)D=OA1⟶+nA1A2⟶+A2B1⟶,where D represents the actual distance between the sensor lens and the reference plate, which are directly read by the depth sensor. OA1⟶, A1A2⟶,A2B1⟶ are three unknowns in equation (5). According to the calculation rule of the vector, the relationship between the three unknowns can be obtained:(6)OA1⟶=OA1⟶V1⟶,OB1⟶=OA2⟶+A2B1⟶B1B2⟶,=OA2⟶+A2B1⟶V2⟶,A1A2⟶=OA2⟶−OA1⟶.Substituting equation (6) into equation (5), we can get(7)OA1⟶=−D−A2B1⟶−n2OB1⟶T∗V1⟶±D−A2B1⟶−n2OB1⟶T∗V1⟶2−n2−1n2OB1⟶2−D−A2B1⟶2n2−1.Therefore, after putting equations (6) and (7) in equation (5), there is only one unknown A2B1⟶. According to equation (4), the back surface depth data corresponding to each pixel of the rear surface can be estimated. Combined with equation (6), the surface points of the front and back of the transparent material can be estimated:(8)OA2⟶=OB1−⟶A2B1⟶V2⟶,OA1⟶=OA1⟶V1⟶.So, the normal map can be resolved by equation (2) or equation (3). The depth data used in equation (4) only comes from the depth value directly read by the depth sensor. In practice, as the depth sensor usage time becomes longer during the experiment, the noise also increases [19]. We propose using a regularization method to reduce noise interference. A regularization term is introduced for each pixel. di is the estimated noise-free TOF optical length and di′ is the actual depth value reads. The noise suppression optimization equation is given by(9)A2B1⟶=argminA2B1⟶∑i∈ISNi⟶−Ni⟶22+λ∑i′∈Nidi−di′22.The above equation can be interpreted as an estimate of the shape of the rear surface becauseA2B1⟶ corresponds to the depth data of the rear surface. To avoid calculating the second derivative with high computational complexity, the L-BFGS method [20] is utilized here. It only uses approximate Hessian matrices instead of calculating them specifically.


## 2.3. Patching Holes in Low-Resolution Depth Maps

In the above measurement model, the integrity of the transparent material depth data acquisition is critical. The low-cost TOF depth sensor has a lower resolution. Besides, the depth map obtained is usually affected by complex factors so that holes often appear at the edges and occlusions of the object. It seriously affects subsequent processing and information extraction [21]. Figure 5 is an example of holes in a depth map, where too bright (Gray value of 255) and too dark (Gray value of 0) are the positions of holes. Generally, the area where the transparent material is located is prone to holes, including small and large areas. The depth value represented by the hole position is not valid. In other words, the lack of depth data occurs. Patching the holes in the depth map is an important part of using low-cost TOF depth sensors to detect the distance between the surfaces of the transparent material.Figure 5
Examples of holes in the depth map. The object in the red box is transparent materials.A hole patching method based on a convolutional neural network is proposed. First, the depth map is generated and the hole position is detected to generate a hole mask map. Then, the hole mask map and original depth map are fed into the deep convolutional neural network to achieve unsupervised hole patching.Untrained deep convolutional neural networks are used, in which the weights are randomly initialized. In the autonomous unsupervised learning process, the network weight parameters needed for depth map patching are generated. That is, based on the given damaged depth map and task-dependent observation model, a randomly initialized convolutional neural network is given. The model parameters are provided by iterations to make it close to the maximum likelihood value. In this paper, the depth map patching task is represented as a problem of energy minimization, given by(10)x∗=minxEx;x0+Rx,where x,x0 are the depth map generated by the neural network and the original depth map with holes. Ex;x0 depends on the specific application scenario, which mainly compares the difference between the generated data and the original data. In equation (10), it is necessary to find the value of x that minimizes Ex;x0 and as the output x∗ of the final network. Rx is a priori knowledge of the depth map, which is often captured by training a convolutional neural network with a large sample. But here, the implicit prior information captured by the convolutional neural network is used to replace Rx. The convolutional neural network learns from the input randomly coded image to the mapping of the original depth map with holes. x∗ is reconstructed from the optimal solution θ∗ obtained by learning. So, equation (10) becomes(11)x∗=fθ∗z,θ∗=argminθEfθz;x0,where θ is the network parameters and θ∗ is the optimal solution of the parameters obtained by Adam gradient descent algorithm training based on the random initialization network. The random vector z is the input code of the network. Once the optimal parameters are obtained, the input z can be calculated to obtain the optimal x. Therefore, the idea of the algorithm is essentially the process of searching for the optimal θ in the feasible space. Use the gradient descent [22] method to randomly initialize the parameters to obtain the (local) minimizer θ.Figure6 is the network structure of the depth map patching algorithm. The overall structure is an Encode-Decode network structure. Input random code z, original depth maps containing holes, and hole mask maps and then let the convolutional neural network autonomously learn the mapping from original pixel values of the input randomly coded z to the original depth map containing the holes according to the areas without holes in the hole mask map. The model network is formed by the cascade of encoding compression (encoder) and decoding reconstruction (decoder). The sampling unit of each layer includes a convolution layer (convolution), a batch normalization layer (BN, batch normalization) [23], and the nonlinear activation function layer (LReLU, Leaky ReLU) [24]. As shown in Figure 6, the downsampling unit uses a convolution layer and the upsampling unit uses nearest-neighbor interpolation convolution. We use the “Meshgrid” image as the input code. Subsequent experiments show that this type of input will increase the smoothness. It is useful for hole patching.Figure 6
The network structure of the depth map patching algorithm.The number of filters in the downsampling unit and the upsampling unit is 16, 32, 64, 128, 128, and 128. The kernel size is 3 and 5. These are all fixed values. After each convolutional layer, there is a BN layer to normalize the data to improve the details of image restoration. In the convolutional neural network, it is necessary to utilize the activation function as a nonlinear transformation. Complex mapping relationships can be learned. In the algorithm, there is a Leaky ReLU activation function after each BN layer, given by(12)LeakyReLUxi=xi,xi≥0,axi,xi<0.


## 3. Experiment Verification

To verify the effectiveness of our method, this paper builds an experimental setup as shown in Figure7. The large transparent material is thick glass with a flat and smooth surface. A low-cost TOF depth sensor based on the continuous-wave modulation measurement method is Microsoft’s Kinect V2, which costs less than $150.Figure 7
Experimental setup.


### 3.1. Patching Algorithm Experiment and Result Analysis

To verify the performance of the algorithm, the built experimental device was used to collect the depth map of the transparent glass cylinder, as shown in Figure5. The image resolution is 512 × 424 pixels. Figure 8 indicates the iterative patching process of depth maps based on convolutional neural networks.Figure 8
Depth map generated during the convolutional neural network patching process.As can be seen from Figure9, not only is it effective for small and larger holes in the transparent materials we care about but also it is possible to patch larger holes at the loading platform. Another advantage of our method is to obtain a good patching effect without affecting the clarity of the original image.Figure 9
Convolutional neural network patching effect.The comparison experiment of the patching effect is adopted to compare the traditional median filtering method, Gaussian filtering method, bilateral filtering method, joint bilateral filtering method, and the method in this paper. Some key parameters of these algorithms in the experiment are set as follows: the filtering window in the median filtering method is 4 × 4. The filtering window in the Gaussian filtering method is 10 × 10. The standard deviation of the filter is 1 pixel. The filtering radius of the bilateral filtering method is 5. The filtering variance is 5, and the local variance is 0.5. The processing effect is illustrated in Figure10.Figure 10
Comparison of various algorithms for hole patching. (a) Original depth map. (b) Median filtering method. (c) Gaussian filtering method. (d) Bilateral filtering method. (e) Joint bilateral filtering method. (f) Convolutional neural network method.
(a)(b)(c)(d)(e)(f)Figure11 further shows the hole patching effect of the transparent glass cylinder and the corresponding error distribution diagram. A comprehensive comparison of the hole patching effects of traditional algorithms shows that the proposed algorithm has obvious advantages. The median filtering method can better fill the small holes. But it is not appropriate for the large area of the hole because the pixel value of this part will be replaced by the median value of the neighboring pixels. This will lead to a larger depth error, thereby losing the original depth information of the object. Although the Gaussian filtering method patches some of the holes, it leads to the edge information of the measured object in the image be too blurred. It will bring greater calculation errors. Bilateral filtering can reduce the loss of depth information at the edges. However, a large area of the hole cannot be patched. The joint bilateral filtering method can patch some small and a part of the larger holes. However, holes on the edges of transparent objects cannot be patched. Even if the parameters are manually adjusted for patching, the transparent objects in the depth map after patching will be blurred to a certain extent.Figure 11
The corresponding error distribution map of hole patching. (a) Original depth map. (b) Median filtering method. (c) Gaussian filtering method. (d) Bilateral filtering method. (e) Joint bilateral filtering method. (f) Convolutional neural network method.
(a)(b)(c)(d)(e)(f)


### 3.2. Experimental Evaluation of the Measurement Model

For the calibrated Kinect depth sensor, a set of Gray code images was collected at two different distances. The two distances selected in the experiment are 60 mm and 75 mm away from the Kinect depth sensor. Figure12 shows a set of Gray code images at a distance of 75 mm from the transparent material and the Kinect depth sensor.Figure 12
A set of Gray code original images. (a) A set of Gray code images with transparent objects. (b) A set of Gray code images without transparent objects.
(a)(b)The Gray code image sequence taken in this experiment is illustrated in Figure12. The vertical Gray code image sequence encodes the horizontal coordinate position of the image. The horizontal Gray code image sequence encodes the vertical coordinate position of the image. Due to the near-infrared camera resolution limitations of the low-cost Kinect depth sensor, only 7 different Gray code images were selected in the experiment.Figure13 shows a single image in the Gray code image sequence. For the decoding of Gray code images, we take vertical Gray code fringe images as an example. We observe the pixels in the blue and red circles in Figure 13(a). Assuming that there is only one pixel in the circle. A pixel in the blue circle is located in the white area and the corresponding Gray code value is 0. A pixel in the red circle is in the black area and the corresponding Gray code value is 1. After the sequence changes according to this rule, the code in the blue circle is 1000010 and the code in the red circle is 0101101. The two codes are translated into decimals of 66 and 45, respectively. These are the horizontal coordinate values corresponding to the two pixels at their respective positions. Use the same method to find the vertical coordinate values, and traverse each pixel in the image to get the corresponding decimal coordinates. The decimal coordinates of each pixel in the image without transparent objects are also achieved in the same way. Finally, the two decimal coordinates of each pixel are correspondingly subtracted to obtain the three-dimensional distortion point of the position.Figure 13
A Gray code image. (a) A single Gray code image with transparent objects. (b) A single Gray code image without transparent objects.
(a)(b)The three-dimensional distortion point at a distance of 60 mm from the depth sensor is acquired using the same process. The difference between the three-dimensional distortion points at two different distances is the reference light direction. Depending on the theoretical analysis in Chapter 2, point cloud images of the front and back surfaces of the transparent material can be obtained. Figure14 shows a point cloud image that is issued by the Gray code image sequence.Figure 14
Point clouds of transparent material.For the transparent object with flat surfaces, the distance between surfaces is detected by the corrected corresponding points on the front and back surfaces. Table1 is part of the distance data between surfaces (unit: mm). The true thickness is 30.000 mm.Table 1
Part of the distance data between surfaces (mm).
Point 1Point 2Point 3Point 4Point 5Point 6Point 7Point 8Point 9Point 10Distance value29.77229.92730.36229.89630.17230.01930.22929.96530.13630.121To verify the performance of our method, two transparent objects with large flat surfaces differing only in thickness were used for the detection. This experiment evaluates the method by obtaining the root mean square error (RMSE) between the surface spacing and the true thickness as follows:(13)RMSE=1m∗n∑im∗nyi−y^i2,where m∗n represents the image size, i is ith pixel in the image, yi is the true thickness of a transparent object, y^i represents the actual distance between surfaces, and yi−y^i represents the error value between the two data.Figure15 shows the RMSE distribution curve of transparent objects of 30 mm and 25 mm thicknesses. It shows the error range of the detection results. In our method, RMSE of the 30 mm and 25 mm transparent objects are 0.2586 mm and 0.3417 mm, respectively. Relative minimum errors can reach 0.86% and 1.3668%, respectively. The reason for different detection accuracy is primarily the optical path length of the refracted light inside the transparent material becomes longer as the thickness of the transparent material increases. Because the degree of deformation of the Gray code will be more obvious, low-resolution cameras can record better. So, the detection result is more accurate. The experimental data are given in Table 2.Figure 15
RMSE distribution maps of transparent objects of different thicknesses.Table 2
Measurement error analysis of transparent objects.
NumberNominal thickness (mm)RMSE (mm)Relative minimum errors (%)1300.25860.862250.34171.3668Experimental results show that the proposed image quality is comparable to [17]. The denoising method proposed in this paper can effectively avoid the adverse effects of noise on reconstruction results. It is worth noting that the reconstruction accuracy is higher than that of [9, 10] mainly because the length of the refracted light path inside the transparent object becomes longer with the increase of the thickness of the transparent object, and the deformation degree of the Gray code becomes more obvious.


## 3.1. Patching Algorithm Experiment and Result Analysis

To verify the performance of the algorithm, the built experimental device was used to collect the depth map of the transparent glass cylinder, as shown in Figure5. The image resolution is 512 × 424 pixels. Figure 8 indicates the iterative patching process of depth maps based on convolutional neural networks.Figure 8
Depth map generated during the convolutional neural network patching process.As can be seen from Figure9, not only is it effective for small and larger holes in the transparent materials we care about but also it is possible to patch larger holes at the loading platform. Another advantage of our method is to obtain a good patching effect without affecting the clarity of the original image.Figure 9
Convolutional neural network patching effect.The comparison experiment of the patching effect is adopted to compare the traditional median filtering method, Gaussian filtering method, bilateral filtering method, joint bilateral filtering method, and the method in this paper. Some key parameters of these algorithms in the experiment are set as follows: the filtering window in the median filtering method is 4 × 4. The filtering window in the Gaussian filtering method is 10 × 10. The standard deviation of the filter is 1 pixel. The filtering radius of the bilateral filtering method is 5. The filtering variance is 5, and the local variance is 0.5. The processing effect is illustrated in Figure10.Figure 10
Comparison of various algorithms for hole patching. (a) Original depth map. (b) Median filtering method. (c) Gaussian filtering method. (d) Bilateral filtering method. (e) Joint bilateral filtering method. (f) Convolutional neural network method.
(a)(b)(c)(d)(e)(f)Figure11 further shows the hole patching effect of the transparent glass cylinder and the corresponding error distribution diagram. A comprehensive comparison of the hole patching effects of traditional algorithms shows that the proposed algorithm has obvious advantages. The median filtering method can better fill the small holes. But it is not appropriate for the large area of the hole because the pixel value of this part will be replaced by the median value of the neighboring pixels. This will lead to a larger depth error, thereby losing the original depth information of the object. Although the Gaussian filtering method patches some of the holes, it leads to the edge information of the measured object in the image be too blurred. It will bring greater calculation errors. Bilateral filtering can reduce the loss of depth information at the edges. However, a large area of the hole cannot be patched. The joint bilateral filtering method can patch some small and a part of the larger holes. However, holes on the edges of transparent objects cannot be patched. Even if the parameters are manually adjusted for patching, the transparent objects in the depth map after patching will be blurred to a certain extent.Figure 11
The corresponding error distribution map of hole patching. (a) Original depth map. (b) Median filtering method. (c) Gaussian filtering method. (d) Bilateral filtering method. (e) Joint bilateral filtering method. (f) Convolutional neural network method.
(a)(b)(c)(d)(e)(f)


## 3.2. Experimental Evaluation of the Measurement Model

For the calibrated Kinect depth sensor, a set of Gray code images was collected at two different distances. The two distances selected in the experiment are 60 mm and 75 mm away from the Kinect depth sensor. Figure12 shows a set of Gray code images at a distance of 75 mm from the transparent material and the Kinect depth sensor.Figure 12
A set of Gray code original images. (a) A set of Gray code images with transparent objects. (b) A set of Gray code images without transparent objects.
(a)(b)The Gray code image sequence taken in this experiment is illustrated in Figure12. The vertical Gray code image sequence encodes the horizontal coordinate position of the image. The horizontal Gray code image sequence encodes the vertical coordinate position of the image. Due to the near-infrared camera resolution limitations of the low-cost Kinect depth sensor, only 7 different Gray code images were selected in the experiment.Figure13 shows a single image in the Gray code image sequence. For the decoding of Gray code images, we take vertical Gray code fringe images as an example. We observe the pixels in the blue and red circles in Figure 13(a). Assuming that there is only one pixel in the circle. A pixel in the blue circle is located in the white area and the corresponding Gray code value is 0. A pixel in the red circle is in the black area and the corresponding Gray code value is 1. After the sequence changes according to this rule, the code in the blue circle is 1000010 and the code in the red circle is 0101101. The two codes are translated into decimals of 66 and 45, respectively. These are the horizontal coordinate values corresponding to the two pixels at their respective positions. Use the same method to find the vertical coordinate values, and traverse each pixel in the image to get the corresponding decimal coordinates. The decimal coordinates of each pixel in the image without transparent objects are also achieved in the same way. Finally, the two decimal coordinates of each pixel are correspondingly subtracted to obtain the three-dimensional distortion point of the position.Figure 13
A Gray code image. (a) A single Gray code image with transparent objects. (b) A single Gray code image without transparent objects.
(a)(b)The three-dimensional distortion point at a distance of 60 mm from the depth sensor is acquired using the same process. The difference between the three-dimensional distortion points at two different distances is the reference light direction. Depending on the theoretical analysis in Chapter 2, point cloud images of the front and back surfaces of the transparent material can be obtained. Figure14 shows a point cloud image that is issued by the Gray code image sequence.Figure 14
Point clouds of transparent material.For the transparent object with flat surfaces, the distance between surfaces is detected by the corrected corresponding points on the front and back surfaces. Table1 is part of the distance data between surfaces (unit: mm). The true thickness is 30.000 mm.Table 1
Part of the distance data between surfaces (mm).
Point 1Point 2Point 3Point 4Point 5Point 6Point 7Point 8Point 9Point 10Distance value29.77229.92730.36229.89630.17230.01930.22929.96530.13630.121To verify the performance of our method, two transparent objects with large flat surfaces differing only in thickness were used for the detection. This experiment evaluates the method by obtaining the root mean square error (RMSE) between the surface spacing and the true thickness as follows:(13)RMSE=1m∗n∑im∗nyi−y^i2,where m∗n represents the image size, i is ith pixel in the image, yi is the true thickness of a transparent object, y^i represents the actual distance between surfaces, and yi−y^i represents the error value between the two data.Figure15 shows the RMSE distribution curve of transparent objects of 30 mm and 25 mm thicknesses. It shows the error range of the detection results. In our method, RMSE of the 30 mm and 25 mm transparent objects are 0.2586 mm and 0.3417 mm, respectively. Relative minimum errors can reach 0.86% and 1.3668%, respectively. The reason for different detection accuracy is primarily the optical path length of the refracted light inside the transparent material becomes longer as the thickness of the transparent material increases. Because the degree of deformation of the Gray code will be more obvious, low-resolution cameras can record better. So, the detection result is more accurate. The experimental data are given in Table 2.Figure 15
RMSE distribution maps of transparent objects of different thicknesses.Table 2
Measurement error analysis of transparent objects.
NumberNominal thickness (mm)RMSE (mm)Relative minimum errors (%)1300.25860.862250.34171.3668Experimental results show that the proposed image quality is comparable to [17]. The denoising method proposed in this paper can effectively avoid the adverse effects of noise on reconstruction results. It is worth noting that the reconstruction accuracy is higher than that of [9, 10] mainly because the length of the refracted light path inside the transparent object becomes longer with the increase of the thickness of the transparent object, and the deformation degree of the Gray code becomes more obvious.


## 4. Conclusions

Faced with the problem of detecting distance between surfaces of the transparent material with large area and thickness, we propose a method based on low-cost TOF continuous-wave modulation and depth map patching. We start with the optical expressions inherent in TOF depth sensors. Based on the analysis of the imaging principle of the depth sensor, the encoding and decoding operations combined with the Gray code are used to effectively achieve the distance detection between surfaces of the transparent material. At the same time, given the problem that the depth map generated by the low-cost TOF depth sensor contains many holes that have a huge impact on the detection, a repair method of the deep convolutional neural network is proposed. It effectively improves the performance of the entire detection system.In addition, although we achieve better detection results, the method in this paper is not appropriate for the case where the refractive index of the transparent material changes. In the future, the relevant theoretical model will be improved and the experimental device will be adjusted to make it suitable for internal uneven transparent material.



---

*Source: 8340179-2021-10-18.xml*