A New Method for Detecting Compensation Hole Parameters of Automobile Brake Master Cylinder Based on Machine Vision

+e machining accuracy of the compensation hole of the automobile brake master cylinder directly determines the safety of the automobile and the reliability of parking. How to detect the parameters of the compensation hole with high precision becomes a crucial issue. In this paper, by analyzing the principle of Hough transform detection technology and several optimization algorithms, a new method combining Zernike moment and improved gradient Hough transform is proposed to detect the circular hole parameters. +e simulation experiment shows that the proposed algorithm satisfies 0.1 pixels in the coordinate detection of the center position, and the radius detection accuracy is 0.05 pixels, with fast detection speed and good robustness. Compared with the random Hough transform algorithm and the gradient Hough transform algorithm, the algorithm proposed in this paper has higher detection accuracy, faster detection speed, and better robustness, which meets the online detection accuracy requirements of the brake master cylinder compensation hole.


Introduction
With the development of society, automobiles are also increasing. e reliability of automobile braking systems has become an important issue to be considered in the development of the automobile industry. At present, the compensation hole hydraulic brake master cylinder [1][2][3] is still an important part of the automobile brake system. e purpose of the brake master cylinder is to transfer the pressure of the driver on the brake pedal through a vacuum booster to the brakes of the four wheels so that the vehicle can decelerate or stop. As a key part of adjusting the brake fluid in the reservoir and pressure chamber of the automobile's brake master cylinder, its dimensional accuracy and processing quality are strictly controlled. Taking the brake master cylinder of ZDZG-22.2-12.385-1 as an example, the nominal size of the compensation hole diameter is 0.7 mm, and the dimensional accuracy is ±0.021 mm. e service life requirement of brake master cylinder of automobile in China is to achieve 500,000 times at normal temperature and 120,000 times at 70°C. However, if the size of compensation hole does not meet the precision requirement, it cannot play the role of accurately controlling the speed of the brake fluid adjustment and the brake will fail, so the number of uses is far less than the use requirements; thus, the size of the compensation hole of the master cylinder must strictly meet the accuracy requirements. However, because the compensation hole of the automobile brake master cylinder is located on the inner side wall of the deep cavity blind hole [4], the existing measuring methods mainly include contact measurement and noncontact measurement, the contacttype measuring is mainly mechanical, such as coordinate measurement. Some scholars have proposed other contact measurement methods. For example, Professor Masuzawa of Tokyo University of Japan proposed a method for measuring deep-hole inner diameter by oscillating scanning measurement. e measurement method is to apply an oscillating circuit to the probe. When the probe contacts the hole wall, the circuit is online and disconnected when it is not in contact. e length of signal that can be detected is determined by the distance between the probe and the hole wall. e aperture is determined by the duty cycle of the signal.
Although the contact measurement guarantees the accuracy of dimension to a certain extent, it is difficult to guarantee the real-time detection, and it will produce certain wear on the workpiece. e sampling and individual measurement methods of contact measurement lay a great hidden danger to the reliability of the automobile brake system. With the development of noncontact measurement, noncontact measurement has attracted more and more attention of scientific researchers due to its advantages such as no force on workpiece, fast detection speed, and high detection accuracy. Relevant scholars have developed a large-scale spy bore system based on CCD-TV [5], which can save and recall the observed images and qualitatively observe the aperture through optical means. However, the equipment is large and bulky, which is not easy to operate. Subsequently, in Zhang [6] et al.'s study, by using the structure of periscope and cooperating with grating ruler and stepper motor, the aperture measurement was realized. Wang [7] et al. developed a device for measuring position parameters of compensation hole by means of human-machine interaction. However, due to manual participation, the diameter of compensation hole detected is affected by workers' actual working experience and fatigue level, and its detection accuracy is low. Du et al. [8], based on LabVIEW software, using image processing algorithms such as filtering, segmentation, and fitting, designed a set of high-precision visual inspection systems with high detection accuracy and fast processing speed, which provides important help for modern hole-type parts inspection method.
With the continuous development of machine vision, with its advantages of high efficiency, accuracy, and stability, it has become a very good method for noncontact measurement [9][10][11][12]. rough image processing algorithm, the parameter detection of target in image is completed, in which Hough transform detects target in image through space conversion and achieves better results. e circle Hough transform (CHT) is a parameter estimation algorithm based on the voting principle proposed by Hough in 1962 [13][14][15]. Circle Hough transform maps the sample points to the parameter space by using the transform of two coordinate systems and then determines the circular parameters by finding the peak value in the parameter space by using statistical voting or building an accumulator. Circle Hough transform has good robustness and antinoise ability. However, because the traditional Hough transform is a oneto-many mapping, there are problems such as a large amount of calculation, a large amount of resources, and a long detection time. In 1993, Xu et al. [16][17][18] proposed the Randomized Hough Transform algorithm (RHT), based on the principle that three points that are not on a straight line can determine the center of the circle, realizes many-to-one mapping, avoids a huge amount of calculation, and reduces the demand for memory. Afterwards, the researchers integrated the gradient information into the Hough transform, that is, the gradient Hough transform [19,20], using the principle that the edge point gradient points to the center of the circle, to convert the cumulative matrix of the circle contour from three-dimensional to two-dimensional, but the algorithm is affected by noise serious. erefore, in 2005, Cai and Zhou [21] proposed the gradient symmetry Hough transform, which effectively avoided the influence of noise on the coordinates of the detection circle center position by finding the gradient symmetry point. ere are also some scholars who combine the Hough transform algorithm with machine learning algorithms to achieve very good results in target positioning, size detection, and flaw detection. Cha et al. [22] by combining the Hough transform with the support vector machine algorithm have constructed a robust separator, which automatically detects the bolt tightening and loosening and has real-time performance. Liu et al. [23] completed the detection of fabric point defects by combining the Hough transform and the application of the confrontation network. e defect detection rate is as high as 97.2%, which is better than traditional defect detection algorithms.
However, because these algorithms are based on pixellevel original contour extraction, they cannot meet highprecision detection requirements. For example, the accuracy of the edge detection of the brake master cylinder compensation hole directly affects the detection accuracy of the compensation hole size. If the detection accuracy is only improved from the hardware aspect, it will be very expensive.
erefore, how to implement subpixel edge detection through algorithms has become a research hotspot. Subpixel edge detection is to decompose the target edge pixels to locate more accurate edge positions. As the related algorithms of image edge subpixel detection [24][25][26] are successively proposed and improved and optimized, it is possible to detect the size of high precision. erefore, the algorithm in this paper is combined and improved on the existing algorithm, and a high-precision method for obtaining circle parameters is proposed. e Zernike moment and the improved gradient Hough transform algorithm are combined to detect the circle hole parameters and realize the compensation of the automobile brake master cylinder. e high-precision detection of hole parameters is compared with similar algorithms under the same conditions. It is better than other algorithms in terms of speed, accuracy, robustness, etc. erefore, the algorithm proposed in this paper can realize the real-time online detection requirements of the compensation hole of the automobile brake master cylinder.

Subpixel Image Edge Extraction Based on Zernike Moment
Currently, subpixel edge detection algorithms mainly include moment method [25], interpolation method [27,28], and edge fitting method [29,30].Subpixel edge detection algorithm based on moment method mainly consists of gray moment, space moment, and Zernike moment. Zernike moment is an orthogonal moment [31] proposed by Ghosal and Methrotal in 1993, which solves the problem of redundant information in image processing because polynomials do not possess orthogonality. In this paper, the improved Zernike moment is used to extract the subpixels of the edge of the compensation hole. Figure 1 is the model of the subpixel edge of the image. e circle is the unit circle. e line L represents the ideal edge of the part surrounded by the unit circle. e gray values on both sides of the inner edge of the unit circle L are h and h + k, where k is the gray difference, l represents the distance from the origin to the edge, and ϕ represents the angle between the land x-axes. Figure 2 is the image of Figure 1 rotated by ϕ. At this time, the edge in the unit circle is perpendicular to the x-axis. Let the rotated image be f ′ (x, y), so the following relationship exists: e first step is to calculate the template coefficients of different orders. Using Zernike template [32], the template coefficients M 00 , M 11 , and M 20 of different orders of Zernike moment are calculated, as shown in Tables 1-4. rough the convolution of the template and the image, Zernike's moments Z 00 , Z 11 , and Z 20 of different orders are obtained. Since the Zernike moment Z mn ′ after the image rotation angle ϕ remains the same as the Zernike moment Z mn before image rotation, only the phase angle changes; the following relationship exists: If the rotated Zernike moment is represented by Z 00 , Z 11 , and Z 20 , according to the rotation invariance of formula (1), Z 00 ′ , Z 11 ′ , and Z 20 ′ can be expressed by the following equation: where Z 11 ′ � Z 11 e − iϕ can be expressed in the following form: It can be seen from formula (1) that the imaginary part of Z 11 ′ is 0; then the following relational expression is given: where R e [Z 11 ] and Im [Z 11 ] represent the real and imaginary parts of Z 11 , respectively. en, you can get the ϕ calculation formula as follows: Put the real and imaginary parts of the calculation result Z 11 and the rotation angle ϕinto formula (1), to obtain the Z 11 ′ moment of the image after the image is rotated, as shown below: According to the model in Figure 1, the calculation expressions of different orders of Zernike moment can be calculated after rotation. e relationship of Z 00 ′ is as follows: Simplify and get the expression of Z 00 ′ as follows: e relationship of Z 11 ′ is as follows: e expression of Z 11 ′ obtained by simplification is as follows: e relationship of Z 20 ′ is as follows: Simplify the expression of Z 20 ′ as follows: Solving equations (3), (9), (11), and (13), we can further derive the distance from the origin to the edge l, the gray value h, and the gray value difference kon both sides of the edge, the specific expressions.
Calculate the distance l from the origin to the boundary: Calculate the gray difference value kon both sides of the boundary and the gray value hon one side of the boundary: After determining the inclination angle ϕof the edge, the distance lfrom the origin to the straight line, the gray value h, and the gray difference value k, the subpixel edge determination condition k ≥ k t ∩ l ≤ l t of Zernike moment is passed, and the point satisfying the condition is the subpixel edge point corresponding to the edge of the circular hole, where k t and l t are the threshold of gray difference and the threshold of distance from center to edge, respectively. e threshold value is determined by preexperiment. e larger k t and the smaller l t indicate that the harsher the conditions and the more accurate the subpixel edge was obtained, the same fewer edge points can be obtained.
Finally, while considering the template magnification effect [33], the subpixel coordinate position (x s , y s )of the image is calculated by the following formula. e template effect is that the subpixel edge error is caused by the different size of the selected template, as long as it is calculated on the unit circle. e distance is increased to N/2times the original, and the influence of the template effect can be removed. e specific expression is as follows, where Nis the template size:

Hough Transform Based on Gradient Information
e Hough transform based on gradient information refers to the principle that the gradient direction of all pixels on the edge of the target points to the center of the circle. Due to the introduction of the gradient direction information of the edge, the parameter space is transformed from three-dimensional to two-dimensional, and the coordinate and gradient direction of pixel points on each target edge are made straight lines, and each point on the line is voted, in which the highest voting position is the coordinates of the center of a circle as shown in Figure 3.
e two edge points in Figure 3 are P A and P B . e coordinates of the two points are (X P A , Y P A )and (X P B , Y P B ), respectively. e gradient directions of the two points are : And by calculating the average value of the distance D i from the center coordinate O(X e , Y e ) to each pixel point P i (i � 1, 2, . . . , n)on the edge of the target contour, the radius R of the target circle can be obtained. e specific expression is as follows: In the formula, P ix and P iy are the coordinates of the pixel P i on the edge contour, and D i is the distance between P i and the center of the circle O.By calculating the average value of D i by the following formula, the radius of the target circle R can be obtained: However, the actual image will inevitably be affected by noise during acquisition and transmission, and the line in the gradient direction of edge points does not pass through the center accurately, so large errors will occur in calculating the position of the center of circle, which will affect the detection of the center and radius of the target contour.

Circular Parameter Detection Algorithm Based on Circular Gradient Center Symmetric Point Hough Transform
Due to the Hough transform based on gradient information, in the presence of noise, the normal direction will be offset from the center of the circle. while there are still a large number of invalid accumulation problems in the symmetric Hough transform based on circular gradient. e algorithm in this paper is based on gradient information. It is proposed on the basis of Hough transform and circular gradient symmetry Hough transform. By calculating the detection method of Hough transformation of the center symmetry point of the circular gradient, the algorithm replaces the need to find symmetry points about the X-axis and theYaxis in the circular gradient symmetry method and then accumulates the data on the median bisector of the symmetry point, which causes a lot of invalid accumulation problems. It is proposed to find symmetrical points directly. Because the symmetrical points on the circle pass through Journal of Advanced Transportation the center of the circle, a large amount of invalid accumulation time can be saved to realize the parameter detection of the circular hole. e principle of the Hough transform algorithm based on the center symmetry point of the circular gradient is to randomly select a point on the edge of the target and then search for the symmetry point in the image. e meaning of symmetric point is that the direction of vertical gradient and horizontal gradient are opposite to the direction of selected point. e relationship between the direction and size of the symmetry point is shown in Figure 4.
In the figure, Vrepresents the vertical direction, and Hrepresents the horizontal direction, where the direction of the arrow represents the gradient direction, and its combined direction points to the center of the circle. We can see from the graph that points a and d are symmetrical with respect to origin O, they have similar size on gradient value, opposite vertical direction, and opposite horizontal direction, and the center of the circle passes through the line between points a and d. By finding a point in the rectangle surrounded by point a at the upper-left corner and d by point d at the lower-right corner, the angle between point a and point d is smaller than a fixed threshold θ t , and the value of θ t is determined by a preexperiment. e larger the value is, the more demanding the conditions are, and the fewer points fall in the region. Instead, the more points fall in the region and the more points the center may be voted on. By randomly selecting points on the target edge several times for calculation, the possible center position of the circle is formed at the center of the circle as shown in Figure 5. e center of the circle is calculated as the center of the target circle. e algorithm does not completely rely on the gradient direction to determine the position of the center of the circle while using the gradient. e noise points in the image are removed by searching for the symmetrical points of the center of the circle. In the case of defective edges of the circle image, the parameter information of the circle can also be accurately detected.

Experiment and Result Analysis
According to the Hough transform based on the central symmetry point of the circular gradient and the joint-improved Zernike moment detection algorithm proposed in this paper, the subpixel edge detection is performed for the compensation hole of the automobile brake master cylinder and the parameters of the circular hole are obtained. e image of the hole is only a part of the image. If the entire image is detected, the detection speed will inevitably be reduced. With the development of deep learning, Fast-RCNN based on convolutional neural network that automatically locates and detects the appearance area shows excellent characteristics [35,36], so through network migration, the input layer and output layer of the trained Fast-RCNN network are removed, and the middle layer is retained. By collecting 40 images of compensating holes of different brake main cylinders as training images, the trained network can accurately and quickly detect the area of compensation hole from the image, realize fast positioning of compensating holes, and then only perform edge detection on the area of compensating holes to achieve highprecision detection of compensating hole size. e specific detection steps are as follows: Step 1. Firstly, the trained Fast-RCNN is obtained through network migration, which can quickly locate the compensation hole in the area and then only process the compensation hole in the area.
Step 2. e area of compensation hole detected in Step1 is filtered by Gauss filtering to filter the noise in the image in preparation for the next edge detection.
Step 3. For the noise-reduced image obtained by Step2, the Zernike moment is calculated to obtain the subpixel coordinates of the image edge. Since the internal environment of the automobile brake master cylinder is similar, the subpixel positioning on both sides of the edge can be determined through preliminary experiments. erefore, the values of gray difference threshold k t and distance threshold l t on both sides of edge in subpixel positioning can be determined experimentally in advance; in this article, the values ofk t and l t are predetermined to be 43 pixels and 0.1143 pixels by experiment.
Step 4. e edge detection of the compensation hole is performed through the Sobel operator, the gradient Figure 4: Relation diagram of gradient directions of symmetrical points on a circle. Figure 5: e location of the center of the voting center.
value and direction angle of the edge are calculated, and the gradient image is obtained.
Step 5. Randomly select a point from the position of the edge in the gradient image and find the edge point that is symmetrical to the center of the target edge, that is, the pixel point with similar gradient size and opposite horizontal gradient and vertical gradient.
Step 6. Find the center point of the circle that meets the conditions from the area enclosed by the two edge points. e condition is that the angle difference between the center point of the circle and the two edge points is less than the set threshold θ t , and the center point that meets the condition is voted. Among them, θ t is determined by preexperiment, and the value of θ t is 3°in this algorithm.
Step 7. As shown in Figure 6, calculate the average value of the distance between the center of the circle O and the subpixel point on the edge of the circle through formulas (18) and (19), and record it as the radius R.
Step 8. Draw it in the image.

Detect Ideal Image Experiment.
First, a 500 * 500 image is generated by using the computer, in which a circle with a center of O (220, 280) pixels and a radius of R of 95.5 pixels is generated, in which the background is black, and the circle is white. By comparing the traditional random Hough transform, the Hough transform based on gradient value and the calculation accuracy and frame rate of the algorithm in this paper, as shown in Figures 7(a)-7(d), the red origin in the graph represents the center of the circle detected, and the green circle represents the edge of the circle detected by the algorithm.
rough subjective observation of the circular edge detection effect in the figure, the random Hough and gradient Hough transform have little difference in the center position detection, but they exist on the edge of the circle. e detection algorithm proposed in this paper is obviously superior to the other two detection algorithms in the center of the circular hole and the edge detection effect. e edge parameters of computer-generated circular image are detected, including the size of the image being 500 * 500 pixels, the theoretical center position of the circle O being (220, 280) pixels, and the theoretical radius R being 95.5 pixels. e center position deviation detected by random Hough transform and gradient Hough transformation is between 1 and 2 pixels, and there is no deviation in the center position through the algorithm proposed in this paper. In terms of circular radius detection, the deviation between the radius and the theoretical radius pixel detected by random Hough transform and gradient Hough transform is more than 2 pixels, and through the detection algorithm proposed in this paper, the difference between the detected radius pixel value and the theoretical pixel value is only less than 0.05 pixels, and the detection accuracy is higher. In terms of the complexity of the algorithm, we know that the traditional Hough transform is a typical "one-to-many" mapping. e algorithm time complexity is O(n 3 ). e random Hough transform and gradient Hough transform developed on the basis of it being in complexity aspects have been reduced, but the time complexity of the algorithm is still O(n 2 ), and the algorithm proposed in this paper is simple and the parallel processing method has been adopted to further improve the complexity of the algorithm. e complexity of the algorithm is O(n log n). From the table below, it can also be seen from the processing frame rate that when processing an image with a resolution of 500 * 500 pixels, the frame rate processed by this algorithm is 3, while the frame rate of the other two algorithms is 2, so the processing frame rate of this algorithm is better than the other two algorithms being more suitable for the needs of online detection. e circular parameters detected are shown in Table 5.

Algorithm Robustness Experiment.
Because image is susceptibly contaminated by noise in the process of forming, transmitting, receiving, etc., and image noise will affect the result of image edge detection and then affect the detection accuracy of target size, this article is verified by manually adding noise to the generated image. e robustness of the proposed algorithm is verified. Among them, Gaussian noise is the most widely existing noise in image noise. erefore, by adding Gaussian noise to the generated image, the robustness performance of the algorithm in this paper is verified. In the computer-generated image, the mean value μ � 0 and the variance are, respectively, added. e Gaussian noises of σ � 0.01, σ � 0.05, and σ � 0.1 can be seen from Figures 8(a) and 8(d). With the increase of variance, the noise content in image increases gradually, but the center and edge contour of the circle detected by the algorithm in this paper do not change significantly. Even when the image is heavily contaminated by noise, it still has a good noise resistance, which shows that the proposed algorithm has good robustness.

Actual Detection Experiment of Compensation Hole.
Finally, a motion mechanism and image acquisition system with high accuracy and efficiency are developed and tested on this system [2,37]. is experimental system consists of a high-precision lifting mechanism, an integrating sphere lighting system, a CCD camera, a self-developed double telecentric endoscope system, a motor, and a software processing system. As shown in Figure 9, by rotating the screw, the lifting mechanism with CCD camera enters the interior of the main brake cylinder of the vehicle, illuminates the integral ball illumination device outside the main brake cylinder, collects a clear image of the compensation hole of the secondary cylinder through software, transmits it to the computer in real time, and carries out real-time processing to obtain the contour information of the compensation hole of the standard master cylinder. e algorithm flow is shown in Figure 10. is experiment detects the master cylinder of model ZDZG-22.2-12.385-1, the compensation hole diameter is 0.7 mm, and the detection accuracy is ±0.021 mm.
In order to compare the detection effects of various detection algorithms on the compensation hole being fair, we analyze the two aspects of (1) subjective observation of the compensation hole detection effect and (2) objective data detected by the compensation hole. First, collect a picture of    Journal of Advanced Transportation 9 the compensation hole of the automobile brake master cylinder. e picture of the compensation hole is shown in Figure 11(a). e same compensation hole image is rounded by the random Hough transform mentioned above, the gradient-based Hough transform, and the algorithm in this paper. e edge detection algorithm is implemented. e experimental computer for various algorithms is configured with i7cpu2, 8G memory, Windows 10 operating system, and the software used is MATLAB 2015b. e detection results are shown in Figures 11(b)-11(d).
(1) rough subjective observation, we can see that the edge position of the compensation hole detected by random Hough has a large offset from the actual compensation hole, and the detected circle contour is obviously larger than the contour of the compensation hole, and the error is relatively large. e gradient information-based Hough transform is obviously better than the random Hough transform in the detection effect, and its relative error in the detection of the center position of the compensation hole is small, but there are still some errors in the contour detection of the compensating hole. e joint Zernike moment and the Hough transformation algorithm of the center symmetry point of the circular gradient proposed in this paper have better effect in detecting the parameters of the circular hole. It can be seen from Figure 11(d) that the edge overlaps well with the center position and edge of compensating hole, and there is no obvious offset in the center of compensating hole, which indicates that the detection effect of compensating hole is very accurate.
(2) By recording the objective data of the compensation hole parameters and displaying it in Table 6, it is known from the above that the ZDZG-22.   Table 6, it can be seen that the pixel value of the compensation hole radius detected by the algorithm in this paper has the smallest difference with the standard size pixel value. It is 0.105 pixels, and the frame rate detected by the algorithm in this paper is also higher than the frame rate of the other two calculations. erefore, it can be said that the detection accuracy and detection speed of the algorithm in this paper are due to the other two detection algorithms, using standard gauge blocks. After camera calibration [38,39], the actual size of pix corresponding to each pixel is 0.007291 mm, and the actual diameter D of the brake master cylinder compensation hole is calculated by the formula D � 2 * pix * n � 2 * 0.007291 * 48.105 � 0.70151. (20) Finally, using random Hough transform, gradient Hough transform, and the algorithm in this paper, the same master cylinder compensation hole size is detected 30 times, and the pixel size of each time is recorded to form the experimental data shown in Table 7. e algorithm proposed in this paper calculates the average pixel radius of the compensation hole is 48.002 pixels, and the standard deviation is 0.003, which is better than random Hough transform and gradient Hough transform. e detection accuracy of the average radius is higher than 1.5 pixels. And draw the error between it and the standard size as the error curve shown in Figure 12. It can be clearly seen from the graph that the random Hough transform and gradient Hough transform algorithms have large errors, while the algorithm proposed in this paper has small errors and compensates. e accuracy of the hole radius is controlled within 0.05 pixels, which is significantly better than the other  two detection algorithms. erefore, the algorithm proposed in this paper has fast detection speed, high repeatability, and meets the real-time requirements of industrial sites.

Conclusion
By introducing the algorithm theory of Hough transform and Zernike moment, this paper improves the edge detection algorithm of Hough transform based on gradient direction symmetry and achieves subpixel edge detection by combining Zernike moment. By comparing various Hough transform algorithms and the algorithm in this paper, it is found that the algorithm in this paper can accurately detect the parameter information of compensation hole of brake master cylinder, the radius detection accuracy is controlled at 0.05 pixels, with high detection accuracy, high speed, high repeatability, and good robustness; the new detection method is provided for online detection of compensation hole parameter information of automobile brake master cylinder. Although the proposed algorithm has some advantages in edge detection of compensation hole, how to further improve the speed and accuracy of detection becomes a difficult problem. With the development of deep convolution neural network, it gradually shows better effect in target recognition and semantics segmentation. How to combine classical image processing algorithm with depth learning algorithm? It will be the trend of our future research to apply it to the detection of compensation hole in the automobile brake master cylinder.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.