# Measurement of Large-Sized-Pipe Diameter Based on Stereo Vision
## 2 Materials and Methods
### Three-Dimensional Reconstruction  
The principle of binocular vision is similar to that of human eye imaging. It analyzes the imaging difference of the same object in the three-dimensional space in the left and right cameras of a camera set and reconstructs the three-dimensional geometric information of the object based on the principle of triangulation. Figure 3 shows the process of 3D reconstruction of images captured with the binocular camera based on the principle of triangulation ranging. O\({}_{l}\) and O\({}_{r}\) are the optical centers of the left and right cameras, respectively, \(f\) is the focal length of the cameras, and \(B\) is the  
Figure 1: Schematic diagram of the proposed measurement system. Figure 2: Flow chart of measurement algorithm. center distance between the two cameras. For a point \(P(x,y,z)\) in space, its projection points on the imaging plane of the left camera and that of the right camera are \(P_{l}(x_{l},y_{l})\) and \(P_{r}(x_{r},\)\(y_{r})\), respectively. From the similar relationship of the triangles, the distance \(Z\) between the measured point \(P\) and the camera baseline can be obtained as  
\[Z=\frac{fB}{x_{l}-x_{r}}, \tag{1}\]  
In the left-camera coordinate system, three-dimensional restoration of the measured point \(P\) is performed, and its coordinates \((x_{c},y_{c},z_{c})\) are expressed as  
\[\left\{ \begin{array}{l}x_{c}=\frac{Bx_{l}}{x_{l}-x_{r}}\\ y_{c}=\frac{By_{l}}{x_{l}-x_{r}}\\ z_{c}=\frac{By_{l}}{x_{l}-x_{r}}\end{array} \right., \tag{2}\]  
For any point on the image plane of the left camera, as long as a matching point can be identified on the image plane of the right camera, the three-dimensional coordinates of the point are derivable through point-to-point operations. In the course of feature point matching, a matching relationship is identified between a pair of images. In the measurement method proposed in this paper, the markers projected on the surface of a pipe under test are regarded as feature points for extraction and matching purpose. The low density of feature points naturally leads to low efficiency in traditional feature point extraction and matching algorithms. Therefore, a special feature point extraction and matching algorithm is designed in this paper to realize feature point extraction by screening blob features with DoG and to match feature points based on affine distance transformation. As shown in Figure 4, \(POQ\) is a straight line segment in space, and its projected line segments in the left and right cameras \(C_{L}\) and \(C_{R}\) are \(P_{L}O_{L}Q_{L}\) and \(P_{R}O_{R}Q_{R}\), respectively. According to the properties of affine transformation, the position order of points on the same line and the length proportion remain unchanged, namely  
\[\frac{\left\|P_{L}-O_{L}\right\|}{\left\|Q_{L}-O_{L}\right\|}=\frac{\left\|P_{ R}-O_{R}\right\|}{\left\|Q_{R}-O_{R}\right\|}, \tag{3}\]  
Figure 5 shows the distribution of laser markers on the pipe surface. A row of equidistant laser markers projects on the surface by the laser when the light-beam axis is perpendicular to the plane. However, when the laser is cast onto the surface of a pipe with large curvature, the distribution of laser markers is affected by the curvature. As a result, laser markers with different spacing form on the surface of the pipe. At the same time, the markers projected by multiple lasers also have overlapping areas, forming non-equidistant marker features on the surface of the pipe. On the other hand, due to the large curvature of the measured pipe and the small interval between the laser  
Figure 3: Principle of binocular vision. markers, the line segment formed by three adjacent laser markers can be approximately regarded as a straight-line segment, which satisfies the above-mentioned conditions of affine distance transformation. In summary, when laser markers are used as feature points, the inconsistent spacing and affine-transformation properties of laser markers provide a basis for the matching of feature points.