1. Introduction
Machine visual detection can realize noncontact and online detection [
1,
2,
3], so application of the machine vision has been widely studied [
4,
5,
6]. With the attention of industry being paid to the development of digital manufacturing and metrological support manufacturing, machine vision has also been widely used in industrial measurement [
7,
8,
9,
10]. Shen [
11] proposed a method to detect the surface defects of bearing by machine vision. The measurement system was mainly composed of area scanning camera, lens, LED illuminator and hood, and the imaging of defects can be improved by controlling the image acquisition environment. This method can detect the deformation, rust, scratch and other defects on the bearing cover, and has high precision and efficiency. Moru et al. [
12] developed an accurate gear measurement system based on machine vision. The system was mainly composed of software, sensor, camera and robot. Its calibration accuracy can reach 0.06 pixels, and the measurement algorithm was improved. Finally, the system realized the effective vision measurement of the gear. Wu et al. [
13] proposed a vision measurement method based on three-line structured light to measure the diameter of the ball. After calibrating the internal parameters of the camera, the neural network algorithm was used to correct the camera distortion. Then, the three-line structured light system was calibrated, and the sub-pixel coordinates of the center of the light stripe were extracted to calculate the diameter of the ball. The measurement results meet the requirements of the measurement system. Bao et al. [
14] realized the automatic reading measurement of the multi pointer instrument based on machine vision. During the measurement, the scales on the instrument panel were used to calibrate the plane parameters of the instrument firstly. Then, the pose relationship between the camera theoretical image plane and the measured instrument plane was obtained. Finally, the reading of the instrument was calculated according to the taken image. This method was accurate and effective. Shafts are important industrial parts, and shaft diameter is a dimension often measured in industry. The present work studies a model of measuring shaft diameter by machine vision.
Machine vision measurement of shaft diameter can be divided into two-dimensional measurement and three-dimensional measurement. One part of the two-dimensional measurement is using parallel light imaging. Guo et al. [
15] measured the diameter of tool by telecentric lens. Because of its small field of view, a telecentric lens can only measure small size parts. Gao et al. [
16] used the optical path to transform the laser light into two parallel beams, which irradiated the two sides of the shaft respectively. Then, two CCD cameras were used to record the images on both sides of the shaft to measure the diameter of the shaft. This method can increase dimension of the measurement, but it is not suitable for on-line measurement. Another part of the two-dimensional measurement is to measure the shaft diameter with an ordinary industrial camera. According to symmetry of the shaft, Wei and Tan [
17] calibrated the relationship between the camera and the measured shaft with a shaft of known diameter to measure the shaft diameter. When the difference between the measured shaft diameter and the calibrated shaft one is large, the measurement needs to be calibrated again. Sun and co-workers [
18] modified position parameters between the measured shaft and the camera image plane with a calibration plate to improve the measurement accuracy. Li [
19] developed a measurement system for the geometric dimensions of shaft parts by machine vision. In this system, CCD camera was used to take the image of shaft surface. After the image was grayed, the image noise was removed by wavelet transform. Then an improved single pixel edge detection method based on the canny detection operator was used to complete the edge detection. Finally, the contour of the shaft was obtained by geometric algorithm, and the measurement accuracy can reach 0.01mm. Che et al. [
20] proposed a method to monitor shaft diameter by machine vision. In this method, a high-resolution network camera was used to collect images, and a LED light source was used as a back light source. After fixed the distance between the camera and the workpiece, the actual diameter of the workpiece was measured with a digital caliper, and the corresponding pixel size was determined on the image, so the scale factor between the image size and the actual size can be obtained, and then the change of the actual shaft diameter can be monitored by detecting the change of the shaft pixel edge on the image.
The three-dimensional measurement includes the structured light vision system and stereo vision one. Liu and co-workers [
21] projected the light stripe image of the measured shaft surface onto a virtual plane perpendicular to the measured shaft, and measured the shaft diameter by fitting center of the circle. Liu’s method takes more time to process the data. Liu et al. [
22] proposed a method for on-line measurement of large round forgings with two CCD cameras, and the experimental results showed that the relative error was less than 0.7%. Wu and co-workers [
23] used three laser linear light sources and a camera to collect the images, and measured diameter, roundness and straightness of the round steel by fitting ellipse. The experimental results showed that relative error of measuring the round steel diameter was less than 0.8%, and the repeatability was more than 0.15 mm. Liu et al. [
24] developed a method to measure micro diameter by line structured light vision. A new radial gray center of gravity extraction algorithm was used to detect the pixel coordinates of the light stripe center, and then the measurement model was established. The diameter was obtained by fitting the circle with linear least square method, and the final measurement accuracy can be higher than 2 μm. Gong et al. [
25] proposed a dynamic measurement method of wheel diameter by multi-line structured light vision. The center of the wheel was determined by the image of the laser projected on the wheel set shaft, and the light stripe center of the multi-line structured light image was extracted by a direction-guided algorithm, then the diameter of the wheel set can be calculated. The root mean square error of measurement results was less than 0.5 mm. Zhang et al. [
26] proposed a binocular stereo vision measurement method for the shape of large parts. A priori constraint was established to detect the boundary of the part, and the image edge compensation method was used to realize the initial edge extraction, and then the critical point of the edge laser stripe was extracted, so the contour of the part can be measured by the principle of binocular vision. The highest measurement accuracy was 0.33 mm.
There are two shortcomings in the above work: one is that the method with good measurement accuracy is only suitable for measuring small diameter; the other is that the model of measuring diameter is not unified, that is, the model is established for specific needs. In this paper, a shaft diameter measurement method is proposed using line structured light vision by establishing a unified model of diameter measurement. The block-diagram of the shaft diameter measurement method is shown in
Figure 1. Compared with the existing vision measurement methods of the shaft diameter, this method can realize the in-situ and on-line measurement of shaft diameter only by a single image, so it features low cost and high efficiency. In addition, the established measurement model has good universality and accuracy, it is suitable for the measurements whose shape is ellipse (or circle) on the laser plane, and if the accuracy of the detected points on the ellipse can be guaranteed, the accuracy of the measurement results using the measurement model can be very high. The imaging principle of an ordinary camera is a pinhole model, and the pinhole model can be used to describe the actual three-dimensional imaging process of the camera, which can establish the relationship between the measured three-dimensional coordinate points in space and two-dimensional coordinate points on image. Therefore, the pinhole model is suitable for three-dimensional measurement based on the two-dimensional image. However, the pinhole model has perspective projection distortion [
27,
28,
29,
30,
31]. To solve the influence of the projection distortion on the measurement, an oblique elliptic cone representing the actual imaging process is derived, and then a universal vision measurement model for the shaft diameter is established. Finally, the validity and accuracy of the measurement model are verified by the experiment, and the measurement results meet the requirements.
The structure of this paper is as follows.
Section 2 establishes the model of shaft diameter measurement.
Section 3 tests the model and analysis.
Section 4 is the conclusion of the full text.
2. Establishment of the Model of Shaft Diameter Measurement
Because the ordinary industrial camera is used for the imaging, the model of diameter measurement is established by the principle of pinhole imaging. To establish the measurement model, the influence of the projection distortion on the measurement needs to be solved first. When the object surface is not parallel to the image plane, the projection distortion causes dimension of the object surface corresponding to the pixels at different positions on the image to be different.
System of shaft diameter measurement from the line structured light vision is shown in
Figure 2. To describe the ellipse formed by intersection of the light plane and the measured shaft surface, a world coordinate system is established. The origin of the world coordinate system is at optical center of the camera, the
−
coordinate plane of the world coordinate system is parallel to the light plane, the
axis is parallel to long axis of the ellipse, the
axis parallel to the minor axis, and the
axis is perpendicular to the light plane. In this world coordinate system, the ellipse formed by the intersection of light plane and shaft surface can be expressed as:
where
are center coordinates of the ellipse,
is radius of the measured shaft, and
θ is the angle between rotation axis of the measured shaft and the light plane.
Oblique elliptic cone with ellipse of Equation (1) as the base and the camera optical center as the top can be expressed as:
When the object surface is not parallel to the image plane, distance from each point on the object surface to the image plane is different. If the attitude of the object surface relative to the image plane is mastered in the imaging space (i.e., the camera coordinate system), we can know the influence of projection distortion on shaft diameter measurement. From mathematics, in the camera coordinate system, the position of the light plane relative to the image plane is determined by the coordinates
of the ellipse center and the normal vector
of the light plane. Therefore, the normal vector
of the light plane is used to determine the transformation relationship
between the world coordinates and the camera coordinates (see
Appendix A). The world coordinates of Equation (2) are transformed into the camera coordinates by
and written into matrix form:
where
.
After the transformation matrix
is multiplied by the coefficient matrix, the above formula is expressed as:
The specific expressions of each parameter in the matrix are shown in
Appendix B. Equation (4) represents an oblique elliptic cone with the ellipse formed by the intersection of the optical plane and the shaft surface as the base and the optical center of the camera as the top. Therefore, according to the principle of pinhole imaging, simultaneous Equation (4) and equation
can obtain the expression of the intersection line between the light plane and the shaft surface on the theoretical image plane:
The coefficient of Equation (5) is only related to the measured shaft diameter (see
Appendix B), that is, Equation (5) has only one unknown quantity. The measured shaft diameter can be obtained by fitting Equation (5) on the theoretical image. Therefore, Equation (5) is the model of shaft diameter measurement.
3. Test and Analysis of the Shaft Diameter Measurement Model
In order to verify the correctness and accuracy of the measurement model, a special test experiment is established. The structure of the test system is shown in
Figure 3. The accuracy of the measurement model is related to the accuracy of the detected measurement points and the camera calibration. The calibration accuracy of the camera’s intrinsic parameters, lens distortion parameters and external parameters can meet the requirements of vision measurement of shaft diameter [
32]. Therefore, after calibrating the camera’s internal parameters and distortion parameters, the influence of the accuracy of the measurement points on the accuracy of the measurement model is tested. The models and main parameters of the equipment used for the test are shown in
Table 1. Since the error of detecting the square corner points of the calibration plate image is very small [
33,
34], the accuracy of the measurement model is tested by the corner points of the calibration plate to reduce the influence of measurement point error on the test. When testing, the surface of the calibration plate simulates the light plane. After calibrating the intrinsic parameters of the camera, the normal vector
and external parameter
of the calibration plate can be obtained by the detected corner coordinates. 4 corner points on the same circle are selected near the camera main point (to reduce the lens distortion) on the calibration plate, as shown in
Figure 4. The symmetrical point of the 4 points is the center of the circle. The 4 points on the same circle on the calibration plate are located in the same ellipse on the image of the calibration plate. Therefore, the pixel coordinates of the ellipse center and four measuring points can be obtained by detecting the image, and the results are shown in
Table 2. Then, in
Table 2,
is the Z coordinate (the world coordinate) of the calibration plate.
According to the principle of least squares [
35,
36,
37,
38,
39], the geometric fitting of the measurement model of Equation (5) is carried out by the data in
Table 2, as shown in Equation (6).
where (
) are the coordinates of the detected corner points; (
) are the coordinates of the points which are both on the ellipse and perpendicular to the point (
).
The diameter of the circle, where the four points on the calibration plate is located, is obtained by optimizing Equation (6) using least squares geometric fitting [
40,
41,
42]. In the experiment, two different known diameters determined by the grid size between the four corner points are selected as exact values for measurement, and the measurement experiment is repeated for 10 times to ensure the effectiveness. In order to verify the stability of the measurement method, change the position of the camera arbitrarily to test again. The position of the original camera is named position 1, and the changed camera position is named position 2. The diameter obtained by the optimizing is compared with the diameter determined by the grid size between the four corner points, as shown in
Table 3 and
Table 4. The data in
Table 3 and
Table 4 show that: the measurement model is correct, which can solve the influence of the projection distortion on the measurement and if the accuracy of the detected points is good, the measurement model has high measurement accuracy.
On a CA6140 lathe, the measurement accuracy of Equation (5) is tested by measuring the shafts with different diameters, as shown in
Figure 5. The measured shafts were installed between the three-jaw chuck and the top of the lathe. The camera is the same as the front test. The laser line source is LH650-80-3. The equation of the connection line between the three-jaw chuck and the top and the optical plane equation are calibrated by Liu and co-workers’ method [
21], the connection line equation calibration system structure is shown in
Figure 6a, the optical plane equation calibration system structure is shown in
Figure 6b. The normal vector of the optical plane in the camera coordinate system is obtained by the optical plane equation calibrated. Because the intersection line between the optical plane and the surface of the measured shaft is an ellipse, the coordinate of the ellipse center can be obtained by the optical plane equation and the equation of the connection line between the three-jaw chuck and the top. The coordinate transformation relationship
is determined by the normal vector of the optical plane and the equation of the connection line between the three-jaw chuck and the top (see
Table A1 and Equation (A13) in
Appendix C).
As shown in
Figure 7, (a) and (b) are the images of the light stripe on the shaft surface when the shaft does not rotate and it rotates, respectively. The midpoints of the light stripe images in
Figure 7a are detected by the Steger method [
43,
44,
45]. Moreover, the pixel coordinates of the detected midpoints are converted into theoretical image coordinates. The measurement accuracy of Equation (5) is tested by the theoretical image coordinates when the measured shaft does not rotate. Similarly, when the measured shaft rotates, the measurement accuracy of Equation (5) is tested by detecting the midpoint of the light stripe image in
Figure 7b. The fit result of an ellipse on the theoretical image plane is shown in
Figure 8. In addition, to ensure the validity of the experiment and the rigor of the research, each test is repeated 10 times, the final measurement results of three different shaft diameters are shown in
Table 5. In
Table 5, the roughness of the shaft is the average of three measurement values obtained by the roughness measuring instrument (TR200), and the known values of the shaft diameters are obtained by the micrometer measurement. The accuracy of the micrometer is 0.001 mm, and the average value of three measurement results of the micrometer is taken as the known value. The measured values in
Table 5 are the average values of repeated measurements.
The data in
Table 5 show that the measurement model Equation (5) is correct, and the measurement results meet the requirement, so in-situ and on-line measurement of shaft diameter can be realized by this method. However, compared with
Table 3 and
Table 4, the measurement error increases, this is because the precision of the calibration plate is 1 µm, the error of detecting the midpoints of the light strip image is larger than the error of detecting the square corner points of the calibration plate image. In addition, when the surface roughness of the shaft is large, there is less specular reflection and more diffuse reflection [
46]. When the rotation speed of the shaft becomes higher, this situation will be aggravated, which cause the image quality of the light stripe on the rotating shaft surface is worse than that on the stationary shaft surface, so that the measurement error of rotating shaft is larger than that of static shaft.
4. Conclusions
This paper studies the measurement of shaft diameter with the structured light system composed of a laser linear light source and a camera, which can realize the in-situ and on-line measurement of shaft diameter. Based on the ellipse formed by the intersection of the light plane and the surface of the measured shaft, the measurement model of shaft diameter is established on the theoretical image plane. The measured shaft diameter can be obtained by optimizing the measurement model with the detected points on the ellipse. The measurement model requires axis of the measured shaft to be unchanged in the position of the machine tool, and general processing machine tools meet this requirement. The experimental results show that the measurement errors of three shafts with different shaft diameters at different speeds are 0.11–0.19 mm, so the measurement model of shaft diameter is accurate, and the measurement accuracy is high, which meets the engineering requirement. Compared with the existing vision measurement technology of the shaft diameter, the measurement method not only solve the influence of the projection distortion on the measurement, but also has good universality, that is, as long as the measurement shape on the laser plane is an ellipse (or a circle, which is the special shape of the ellipse), the measurement method is applicable.
If the detected points have higher accuracy, such as the precision of detecting the square corner points on the calibration plate, the measurement accuracy of the measurement model can be higher. The main factor affecting the measurement accuracy of the model is the error of the detected points on the ellipse, and the error is mainly affected by the surface roughness and the rotation speed of the shaft. Therefore, based on this measurement model, if a higher-precision measurement of the shaft diameter is required, to study the influence law of shaft surface roughness and rotation speed on the detection accuracy of the light stripe center is a desirable research direction.