Shaft Diameter Measurement Using Structured Light Vision

A method for measuring shaft diameters is presented using structured light vision measurement. After calibrating a model of the structured light measurement, a virtual plane is established perpendicular to the measured shaft axis and the image of the light stripe on the shaft is projected to the virtual plane. On the virtual plane, the center of the measured shaft is determined by fitting the projected image under the geometrical constraints of the light stripe, and the shaft diameter is measured by the determined center and the projected image. Experiments evaluated the measuring accuracy of the method and the effects of some factors on the measurement are analyzed.


Introduction
Shafts are one of most important machine elements and the accuracy of machined shafts has a significant effect on the properties of any mechanical device that employs one. The accuracy of a machined shaft can be ensured using a Computer Numerical Control lathe, but mechanical wear in a CNC lathe system, system deformation, and the radial wear of the machining tools will reduce the accuracy of the machined shaft. If the variation of the shaft diameter could be monitored during its machining, the dimensional accuracy of the product could be ensured by the automatic compensation system of the CNC lathe. Therefore, on-line measurement of shaft size is very important in machining.
A variety of noncontact machine vision methods for measuring the product diameters have been proposed [1][2][3][4][5]. These methods can be classified as active methods and passive methods. Passive OPEN ACCESS measurement methods use a camera or two cameras to obtain shaft diameters [6,7]. In 2008, Song et al. [8] proposed a method where both edges of a shaft were imaged onto two cameras through two parallel light paths as shown in Figure 1 [8]. Using this approach, the shaft diameter was obtained by measuring the length of the photosensitive units on the shadow field of the two CCDs (Charge-Coupled Device) and the distance between the two parallel light paths. This method can amplify the measurement range while ensuring the measuring accuracy; however, it is very difficult to calibrate the position of the two cameras. In 2013, Sun [9] used a camera to obtain shaft diameters, employing a theory of plane geometry in the cross-section, which is perpendicular to the axis of the shaft, as shown in Figure 2 [9]. This method can achieve a high measuring accuracy, but it requires the calibration of the plane of the center line of the shaft before the measurement. In practice, the position of the center line changes each time the shaft is clamped by the jaw chucks of the lathe. This change of position will decrease the accuracy of measurement. Active measurement methods generally use one or more cameras and lasers to achieve accurate measurements of shaft diameters. In 2001, Sun et al. [10] used a pair of line-structured lasers and cameras to measure shaft diameters, as shown in Figure 3 [10]. The lights was projected onto the pipe, then captured by two cameras, and the diameter of a steel pipe could be determined by fitting the ellipse with the two developed arcs. It is difficult to ensure that the two arcs are on the same plane, so the accuracy of the method is limited. In 2010, Liu et al. [11] reported a method for measuring shaft diameters using a line-structured laser and a camera, as shown in Figure 4 [11]. The coordinates of the light stripe projected on the shaft were obtained using a novel gray scale barycenter extraction algorithm along the radial direction. The shaft diameter was then obtained by circle fitting using the generated coordinates. If the line-structured light is perpendicular to the measured shaft, the shaft diameter can be obtained by fitting a circle. Thus, this method is limited by the measurement environment.  In this study, a method for measuring shaft diameter is proposed using a line-structured laser and a camera. Based on the direction vector of the measured shaft axis, which is calibrated before the measurement, a virtual plane is established perpendicular to the axis and the image of a light stripe on the shaft is projected to the virtual plane. The shaft diameter is then determined from the projected image on the virtual plane. To improve the measuring precision, the center of the projected image was determined by fitting the projected image using a set of geometrical constraints.
This report is organized as follows: Section 2 calibrates the structured light system. Section 3 outlines the model of the proposed method. Section 4 reports the experimental results used to test the measuring accuracy and influences of several factors. Section 5 provides the study's conclusions.

Calibration of Camera Parameters
The calibration of the measurement system employed world coordinate systems (O i WX i WY i WZ i W), a camera coordinate system (OCXCYCZC), a image coordinate system (oxy), and a pixel coordinate system (Ouv), which were established as shown in Figure 5. Based on pinhole projection and lens distortion models, the mapping from the world coordinates to the pixel coordinates can be expressed as reported by Zhang [12] and shown in Table 1, where R is the rotation matrix; T is translation vector; k1, k2, p1, and p2 are the coefficients of radial and tangential distortions; is the interior camera parameters; ZW = 0 in the model. A nonlinear function can be established by minimizing the distance between the calculated pixel coordinates of the corner points in the calibration board and the actual pixel coordinates. The function was solved using the Levenberg-Marquardt algorithm [13]. Table 1. Coordinate transformation of camera model.

Transformation Equations
From world coordinates to camera coordinates 1 From camera coordinates to image coordinates From image coordinates to pixel coordinates

Calibration of Structured Light Parameters
The calibration model of the structured light is shown in Figure 5. Here, AB is the intersection line between the light plane and the calibration board, P is a point on AB. The pixel coordinate of P can be extracted as described by Steger [14], and camera coordinates of P are determined using Equations (1)- (4). Different intersection lines can be obtained by turning the board, so P i j is the jth point on the intersection line when the board is in the ith position.
Setting the equation of the light plane under OCXCYCZC: The parameters b1, b2, b3 can be determined by the objective function: where n is number of board turns, k is the number of sample points on the intersection line when the board is in the ith position, and (X i Cj,Y i Cj, Z i Cj) are camera coordinates of P i j. According to the principle of least squares, the coefficients of Equation (5) can be solved as: Because the camera parameters and coordinates of the sample points have errors, the coefficients obtained by Equation (7) will be used as initial values for optimizing the light plane. The objective function of the optimized plane is established by the distances between the points and the plane: The parameters of the plane can be obtained using the Levenberg-Marquardt algorithm. In the experiment, when the constant term of Equation (5) is 1, the parameters of the plane are small and the denominator of Equation (8) is around 0. To improve the optimization results, the constant term of Equation (5) is set at 1000 in the paper.

The Principle and Model of the Measurement
The model for measuring the shaft diameters is shown in Figure 6. A shaft is clamped at two centers, images of the shaft are captured by a CCD camera, п1 is the light plane, and MN is the axis of the shaft. The stripe ab is formed by projecting the light plane п1 onto the measured shaft. The pixel coordinates The arc cd is formed by the virtual plane п2 intersecting the measured shaft. Since the light plane п1 is not perpendicular to the shaft, the cross-section is an ellipse and the shaft diameter can be obtained by fitting the ellipse with stripe centers P i . The elliptic equation is: The parameters of Equation (10) can be obtained by the least squares method, and the length of the minor axis d is the measured shaft diameter: Since the virtual plane п2 is perpendicular to the shaft, the cross-section is a circle and the diameter can be obtained by fitting the circle with points Q i , which are P i projecting on the virtual plane п2. The circle equation is 2 2 0 x y ax by c The parameters of Equation (12) can be obtained by the least squares method, and the circle diameter d1 is the measured shaft diameter: Since the pixel coordinates of the extracted stripe centers have errors, from the numerical analysis, the measuring accuracy of the shaft diameter by circle fitting is better than by ellipse fitting (see Appendix B for the detail).
of P i can be achieved using Equations (3) and (4), so the equations of OCP i are: The camera coordinates can be obtained using Equations (5) and (14): A set of lines P i Q i are made by passing through the extracted centers i P and parallel to the measured shaft axis, as shown in Figure 6b. Since the axis MN is perpendicular to the plane п2, the direction vectors of the lines are the normal vector of п2, ' ' ' Thus, the equations of lines P i Q i are:  To facilitate the circle fitting, a coordinate system (Oe-XeYeZe) is established on the plane п2, as shown in Figure 7. In Oe-XeYeZe, XeYe plane is the plane п2, OeZe axis is perpendicular to the plane п2, and the origin of coordinate Oe is the intersection point of the plane п2 with OCZC axis. Additionally, camera coordinates of the origin of Oe ' 3 (0, 0,1000 / ) b can be obtained by Equation (9). Thus, translations of the camera coordinate system are ' 3 (0, 0, 1000 / ) b − relative to Oe-XeYeZe and the camera coordinate Q i can be changed into Oe-XeYeZe by Equation (17) where, ψ is the rotation angle round OCYC, θ is the rotation angle round OCXC, and e ( , , ) θ and ψ are obtained by Equation (18). In Oe-XeYeZe, because points Q i are on п2, the coordinates Q i are ( , ,0) Since arc cd is at a side of the shaft and the coordinates of points Q i on cd have errors, the accuracy of the shaft diameter which is directly measured by fitting points on cd is poor, as shown in Figure 8. In Figure 8, the red circle is a cross-section formed by the virtual plane п2 intersecting with the shaft and Ow is the center of the red circle. The circle obtained by fitting the black points on cd is blue with its center at O. To improve the measuring accuracy, the center is determined by fitting black points under the geometrical constraints of arc cd, and the geometrical constraints for a circle center are shown in Figure 9.
In Figure 9a, A, B, C, D are the fitting points in the circle and O is the center. Point E is the intersection point of AC and BD. From the geometrical feature of a circle, the following relation holds: where r is radius of the shaft. Setting the center coordinate as (x0,y0), the coordinates of the points A, B, C, D are (xa,ya), (xb,yb), (xc,yc), (xd,yd). The coordinate (xe,ye) of point E can be obtained from points A, B, C, D. Thus, the first objective function can be presented as: where the value of r is estimated when optimizing Equation (20); n is number of the points.
Therefore, the center coordinate can be determined by Equations (20)  Finally, the shaft diameter is obtained by the distance between the points in cd and the optimized center: where d is the diameter of shaft, (xi,yi) are coordinates of the points in cd, (X0,Y0) is the coordinate of the optimized center, and n is the number of fitting points.

Experiments and Analysis
Experiments were conducted to assess the utility of the proposed method. The experimental equipment employed is shown in Figure 10 and the main parameters of the equipment are shown in Table 2. The interior parameters of the camera were calibrated by the method presented in Section 2. Two shafts were used in the experiments; shaft 1 was a four-segment shaft and the shaft surface's reflection was reduced using a special process, as shown in Figure 10a. Shaft 2 was a seven-segment shaft, as shown in Figure 10b. The shafts' diameters were measured using a micrometer with a resolution of 1 μm.  First, the images of the shafts were captured using the camera, as shown in Figure 11. The diameters of the shafts were measured using the method described in Section 3. The measurement data are listed in Tables 3 and 4, and the measurement error was less than 25 μm.   To compare the proposed method with the other methods, the diameters of the shafts were obtained by directly fitting the ellipse and circle. The data for these methods are shown in Tables 5 and 6. The measuring accuracy of the present method was found to be better than that of the other two methods. To test the influence of the angle between the light plane and cross-section of the shaft on the proposed method, the shaft diameters were measured by light planes with three different light angles, as shown in Figure 12. Measurement results are listed in Tables 7 and 8.    In order to test the influence of noise on the proposed method, noise with a variance of 0.01 and a mean of zero was added to the stripe images of shaft 1 and shaft 2, as shown in Figures 13 and 14. The center coordinates of the stripe images with the added noise were extracted by Steger's algorithm [14]. The shaft diameters can be determined respectively by the ellipse, circle, and the proposed method fitting the center coordinates. The results are listed in Tables 9 and 10.   Here, the shaft diameters D were obtained by a micrometer, and D Δ is change of the shaft diameter measurements before and after the added noise. As seen in Tables 9 and 10, the noise has little effect on the measuring accuracy of the proposed method.

Conclusions
A method for the measurement of shaft diameters is proposed which is based on a structured light vision measurement. A virtual plane is established perpendicular to the measured shaft axis and an equation for the virtual plane is determined using a calibrated model of structured light measurement. To improve the measurement accuracy, the center of the measured shaft can be obtained by fitting the projected light stripe image on the virtual plane under the geometrical constraints. Using specific experimental conditions, measurement errors of the method were less than 25 μm and the angle between the structured light plane and the measured shaft barely affected the measurement accuracy.

Acknowledgments
The work described in this paper is partially supported by the Foundation of Jilin Provincial Education Department under Grant 201591.

Author Contributions
Siyuan Liu proposed the algorithm, designed and performed experiments, and wrote the initial manuscript. Qingchang Tan conducted the analysis of the algorithm. Yachao Zhang performed experiments.

Conflicts of Interest
The authors declare no conflicts of interest.

Appendix A
Since the virtual plane п2 is perpendicular to the measured shaft, the direction vector of the axis is the normal vector of п2. As shown in Figure A1, the calibration board is fixed by fixtures, and they are clamped by the two centers and the connecting line of the two centers is the axis of the shaft MN. Turning the calibration board, the images of the board can be captured by a camera and MN is the intersecting line of the calibration board planes. Based on Equation (1), Equation (A1) can be obtained: Set to 11 , where, Rj and tj are the rotation matrix and translation vector of the calibration target at the jth position and can be obtained by the method provided in Section 2, j = 1,2.
Since world coordinate systems O j WX j WY j WZ j W are built on the calibration target plane, Z j w = 0. The equation of the calibration target plane at the jth position is: The normal vector of the plane is ( ) .
MN is the intersecting line of the two planes, so the direction vector of MN can be represented as: As shown in Figure 6, Or is a point in п2 and set Or is the intersection point of MN and п1, and the camera coordinate of Or is Or = (Xr,Yr,Zr).
The equation of п2 in OCXCYCZC is Thus, equation parameters of the virtual plane can be obtained using Equations (9) Using 1 x obtained by Equation (B1), the measured shaft diameter can be obtained by Equation (13).
x y x y x y x y xy  x y Using 2 x obtained by Equation (B2), the measured shaft diameter can be obtained by Equation (11). Since the matrixes (A1, A2) and the vectors (b1,b2) in Equations (B1) and (B2) consist of the coordinates of the light stripe centers, the matrixes and vectors are influenced by errors of the light stripe centers' coordinates, which show that 1 x and 2 x are inaccurate. From Numerical Analysis (Seventh Edition) by Burden and Faires [15], the influence is analyzed as shown below.
Considering the errors of the light stripe centers' coordinates, matrix A1 and vector b1 in Equation (B1) are expressed as: x x x = +δ , and Equation (B1) can be expressed as: is an invertible matrix, and from Equation (B4) we get: In order to analyze the error of the fitting circle equation's parameters, the norm of Equation (B5) is: where 1 x δ is error of the circle equation's parameters 1 x obtained by the circle fitting. In the same way, the error of the equation's parameters 2 x for the ellipse fitting can be obtained by Equation (B2) 1