Keywords

1 Introduction

With the advent of the Industry 4.0, China has also put forward the plan of “made in China 2025” for its own industry, and the progress of intelligent manufacturing has gradually penetrated into every corner of the manufacturing industry. The introduction of machine vision in intelligent manufacturing accelerates the pace of industrial development. Machine vision is mainly used in product sorting, vision measurement and artificial intelligence in current industrial manufacturing field [1,2,3,4,5]. In the production process of products, the requirements for the accuracy of products are increasingly higher and higher. The traditional measurement method brings the problems of low efficiency and substandard accuracy, and the introduction of machine vision greatly improves the accuracy and efficiency of measurement.

As a crucial element of industrial production, the gear is essential in the assembly of equipment, but most of them still use manual assembly. In order to realize and replace manual operation, machine vision is introduced into gear assembly operation. In the machine vision system, the application for gear is mainly used in the defect detection of gear and the detection of meshing degree after assembly, and the machine vision is not used in the gear assembly [6, 7]. From the perspective of the application of machine vision in industrial production, the non-contact measurement of objects is mainly realized through camera calibration in the field of measurement. However, the relative position of gear teeth should be measured in the assembly of gears, and the main problem is the angle difference between gears in the assembly process. By determining the attitude and position of each gear, the rotation angle of the gear can be calculated, and the meshing assembly of the gears can be realized through rotation in the assembly process. By means of the gear assembly guided by machine vision, the manual operation in gear assembly can be replaced by machine. In this paper, design the corresponding algorithm for machine vision to realize the assembly of gears in simple cases, which fills the automatic assembly of gears in industrial assembly, and provides a design method for the automatic assembly of gears in complex cases in industrial production, thus the efficiency and safety in the production process can be improved.

2 Working Principle and Structure of Visual System

The hardware of the machine vision system mainly consisted of camera and light source, the camera came mainly from ALLIED Industrial Camera and light source used white-light surface one. The whole design was mainly to complete the recognition and overall positioning of the two industrial gears in the field of view, as well as the positioning of the outer teeth of the gears, and then to calculate the rotation angle of the two gears to be rotated in advance during the translational assembly process of the two gears by means of image processing. The system software engineering mainly included camera calibration, image acquisition, image filtering, binarization, edge processing, and image processing, etc. The detailed design procedures were shown in Fig. 1.

Fig. 1.
figure 1

Flow chart of the system

3 Design of the Image Processing Software

In the design of the image processing, at first it is necessary to determine the field of view that the camera was able to take, and then the light source of the device. The choice of light source determined if the images could achieve the desired effect for post-processing. The objects to be photographed in this design were white industrial gears, so in the selection of the shooting environment, and the white surface light source was selected to be placed above the object to be photographed. Black matte iron plate was selected as the background which was sharp contrast and non-reflective.

3.1 Image Filtering

There may be some impurities in the field of view taken by the camera, which may form noise points in the captured images. At this time, the captured images need to be filtered first. The commonly used filtering includes median filtering, mean filtering, maximum filtering, minimum filtering, Gaussian filtering, etc. [8]. The Gaussian filtering is superior to the mean filtering in edge protection and can meet the requirement of the edge information higher in the design.

3.2 Binarization

The photos taken by the camera in this design were color ones, which will result in slow of computing speed due to the large amount of data in the later image processing. What’s more, the binarization of the original image was adopted, which greatly reduced the memory occupied by each pixel. It was not only reduced the size of the image data, but also made the image edge of the image more clearly. In this design, threshold transformation method was used to realize the conversion of image binarization, as shown in Fig. 2.

Fig. 2.
figure 2

Pre-processing image

3.3 Image Capture

In the process of image processing, the gears in the image need to be processed separately, so the gears in the image need to be recognized and captured before the image processing. The capturing of images was to find the centroid of each gear and the dimension of gear in the images.

Here, we used the property of centroid in regionprops() function to get the centroid position of the gear in the image, while its boundingbox property was also used to get the position and dimension information of each gear in the image. The Boundingbox property was the minimum matrix containing the region. The property could be used to get the coordinates of the upper left corner of the minimum matrix and the length and width values of the minimum matrix.

The two properties of the regionprops() function could be used to capture the location and dimension information of each gear in the binarization image. In order to obtain the better edge features for the subsequent gears, additional tenpixel points were captured at the edge of the gear image when the image was captured. The final captured images of gears were shown in Fig. 3.

Fig. 3.
figure 3

Binarization images of gears captured

3.4 Extraction of Edge Features of Image

Extraction of edge features is the processing of image profile and the edge is the set of points where image pixel value has step change [9, 10]. Since the image had been converted to a binarization image in the previous step, the profile information of gear could be only obtained by four-domain analysis during the extraction of edge features.

There were two kinds of edge information of the gear in the captured image, the outer profile could be used for data post-processing, and the inner hole of the gear were treated as interference information, which used for extraction of profile after filling treatment. And the infill() function was used to fill the empty area in the binarization image. In this way, the area with black part in the gear was filled with white, and then the edge feature of the image was extracted. The final extracted gear profile diagram was shown in Fig. 4.

Fig. 4.
figure 4

Outer profile diagram of gear

3.5 Image Processing

The main function of image processing was to obtain the attitude information of each gear under the current state. Firstly, the center position of the gear in the profile diagram should be found, and the origin of the original coordinate system of the image could be shifted to the center position of the gear, so as to realize the uniform distribution of the gear profile coordinates in the four quadrants. The coordinates of the gear profile in the new coordinate system were calculated again, and then the coordinates in the rectangular coordinate system were converted to ones in the polar coordinate system. Therefore, the set of polar coordinates of the gear profile could be obtained.

$$ {\text{C}}\,{ = }\,\left\{ {\left( {{\text{r}}1,\,\uptheta1} \right),\,\left( {{\text{r}}2,\,\uptheta2} \right), \ldots \, \ldots ,\,\left( {{\text{ri}},\uptheta{\text{i}}} \right)} \right\},\,\left( {{\text{i}},\,\,{\text{Number}}\,\,{\text{of}}\,\,{\text{coordinate}}\,\,{\text{points}}} \right) $$
(1)

With the conversion of the coordinate system, a set of two polar coordinates were obtained, and then they could be arranged in order from small to large according to the θ value in each set. The obtained new coordinate set was plotted to obtain the profile polar coordinate diagram, was shown in Fig. 5.

Observed from Fig. 5, the distribution of polar coordinates of the gear profile presented a sinusoidal wave trend, and the curve fitting performed with the points of the coordinate system. The mathematical model of the fitting formula was following:

Fig. 5.
figure 5

Polar coordinate diagram of gear profile

$$ f\left( \theta \right)\, = \,A \cdot \sin \left( {\omega \theta \, + \,\varphi } \right) $$
(2)

where the A and ω represented the amplitude of the fitting curve and angular frequency, respectively. Since the gear had 20 teeth, the angular frequency was fixed at 20. \( \varphi \) was the initial phase. In order to reduce the computing burden of the computer, the amplitude A of the curve in the formula obtained by the mean value on the vertical axis of the coordinate.

$$ {\text{A}}\,{ = }\,\frac{1}{i} \cdot \sum\nolimits_{j = 1}^{i} {r_{j} } $$
(3)

The fitting curve was shown in Fig. 6.

Fig. 6.
figure 6

Fitting curve diagram of coordinate of gear profile

According to the fitting curve of the polar coordinates of the two gear profiles, the initial phase of the two fitting curves could be get, which included the angles between the connecting line of top end on each gear tooth with the center of the gear. And the horizontal axis was determined by the initial phase. In order to realize the meshing of gears in the assembly process, the meshing between the gear teeth and the tooth slots was needed, which means that the peak and trough of the two gears in the fitting curve had same θ value. The two gears had 20 teeth each, and the curve period was π/10. To achieve meshing of gears, only difference between the initial phase of two fitting curves was required to be integer times of π/20 through calculation.

$$ {\text{rotate}} = \frac{\pi }{20} \cdot k - \left| {\varphi_{1} - \varphi_{2} } \right|\text{}\left( {{\text{k}} = \pm 1, \pm 2, \pm 3, \ldots \ldots } \right) $$
(4)

Through the above calculation, the angle value of gear 2 rotated was obtained when gear 1. In general, the value of k should not be too large. After rotating the gear, the resulting image was shown in Fig. 7.

Fig. 7.
figure 7

Image of gear after rotating

4 Conclusion and Analysis of Experiments

It could be observed which the two gears were engaged rotating the gear under translation for the rotated image. In order to better verify the stability and accuracy of the design, several experiments were carried out to test the system performance under the same condition. The measured data under different placement conditions were shown in Table 1.

Table 1. Measurements of gears after rotation under different placement conditions

By analyzing the data in Table 1, it could be found that the gears were placed by different ways in the same environment, while no error occurred during recognition of image of gears. After processing the image of gear, the initial phase of each gear was obtained. With the initial phase difference of the two gears, the rotation angle of the gears to be assembled were calculated. After rotating the image of the gears to be rotated with the corresponding angle, the rotated image was processed to obtain the curve fitted by the rotated gear edge, and the initial phase of the rotated gear was calculated, as well as the inherent error of the algorithm. The results of gear assembly in the real operation process were thereby simulated. It could be seen from the results that the error of the simulation result obtained by rotating the image after outputting the rotation angle was fallen within the range of 0.01°. As many errors might be introduced in the field operation while the error range of the output result given in the image processing was negligible, which reduced the systematic error caused by followed robot in the assembly process.

5 Summarization

After filtering image, binarization, processing image and taking edge features for the two gears randomly placed in the field of view, computing the initial phase of each gear, and the rotation angle of the gears to be rotated, the meshing of the translation gears could be thus realized. Through the realization of gear meshing assembly guided by machine vision, it filled the gap that industrial gear manual assembly in the process of industrial production and manufacturing could be replaced by machine.

In this paper, the experimental was demonstrated. In the results that the image processing algorithm could realize the recognition of the plane gear and the rotation angle value of the gear to be assembled. And the accuracy of the theoretical rotation angle measured by the experiment within the range of 0.01°. The high-precision output reduced the system error for the field assembly of the subsequent robot.

The idea provided by the algorithm could not only be used to the assembly of flat gears in the industrial production and manufacturing process, but also be extended to the assembly between different types of gears.