A method for detecting scratches on the surface of bearings based on machine vision

By adopting machine vision technology in bearing surface scratch detection, using Hough transformed and improved YOLOv5 target detection network model, combined with CRNN character recognition network, the problems of high error detection rate and high missed detection rate in the existing technology are solved, and high accuracy bearing scratch detection and model recognition are achieved, improving the level of automated detection at industrial sites.

CN115272204BActive Publication Date: 2025-06-10CHINA UNIV OF PETROLEUM (EAST CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210837492.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-15
Publication Date
2025-06-10
Estimated Expiration
2042-07-15

AI Technical Summary

Technical Problem

The existing bearing surface scratch detection technology has the disadvantages of high error detection rate and high leakage detection rate, and has failed to identify bearing models, making it difficult to meet the automation inspection needs at industrial sites.

Method used

Using machine vision-based bearing surface scratch detection method, bearing images are collected through industrial cameras, Hough transforms detect areas of interest, scratch detection data sets are made, and an improved YOLOv5 target detection network model is built, convolutional attention mechanism and anchorless mechanism are added, and bearing model recognition is achieved in combination with CRNN character recognition network.

Benefits of technology

It improves the accuracy of bearing scratch detection, reduces the error detection rate and missed detection rate, realizes accurate identification of scratch-free bearing models, improves the degree of automated inspection at industrial sites, and reduces enterprise manufacturing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115272204B_ABST
    Figure CN115272204B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for detecting scratches on the surface of a bearing based on machine vision. An industrial camera is used in cooperation with an industrial lens and a coaxial light source to collect bearing images, and a bearing surface image dataset is obtained; the Hough transform is used to extract the region of interest; polar coordinate transformation is used to unfold the bearing ring image into a rectangle, and the characters distributed on the ring are converted into a horizontal distribution; a network model for detecting scratches on the bearing surface is built, which is improved based on the YOLOv5 network model. A convolutional attention mechanism is added to the network, the position regression loss function uses the EIoU loss, the detection head uses a decoupled head, and the detection box prediction regression parameter uses an anchor-free mechanism; the PaddleOCR network model is used to train the character recognition network. The present invention effectively improves the program operation efficiency, reduces the false detection rate of scratch detection on the bearing surface, and improves the recall rate of scratch detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of industrial defect detection, and particularly to a method for detecting scratches on the surface of a bearing based on machine vision. Background Art

[0002] With the continuous improvement of the technological level, the profit of traditional manufacturing industry is getting lower and lower, and intelligent manufacturing has become the development direction of modern industrial manufacturing. As the "joints of industry", bearings are widely used in many fields such as railway, aerospace, and agriculture. Manufacturing high-quality bearings has always been the development goal of China's bearing industry. However, during the bearing production process, due to the influence of production processes or the non-standard operation of staff, the surface of the bearing is easily scratched. In the past, the method of manual inspection was usually used to detect scratches on the surface of the bearing, which had a high labor cost and low detection efficiency. Machine vision is a detection technology with a high degree of automation. However, due to the diversity of the positions, sizes, and morphological characteristics of scratch defects on the bearing surface, traditional machine vision image processing methods are difficult to meet the requirements of industrial sites.

[0003] In recent years, deep learning has developed rapidly, and machine vision technology combined with deep learning has also been applied in industrial sites. In the field of deep learning, in order to obtain a neural network model with better performance, a large number of training samples are usually required. However, in the field of bearing defect detection, there is currently no publicly available dataset of scratches on the bearing surface. The bearing model is often printed on the bearing end face. Previous research methods only involve single-sided bearing defect detection and do not achieve the recognition of the bearing model. Moreover, the detection of scratches on the bearing surface has disadvantages such as high false detection rate and high missed detection rate. Therefore, it is an urgent problem to be solved to make a dataset for detecting scratches on the bearing surface, reduce the false detection rate of detecting scratches on the bearing surface, improve the recall rate of scratch detection, identify the model of qualified bearings, improve the degree of automation detection in industrial sites, and reduce the manufacturing cost of enterprises. Summary of the Invention

[0004] The purpose of the present invention is to propose a method for detecting scratches on the surface of a bearing based on machine vision in view of the deficiencies of the existing bearing surface scratch detection technology.

[0005] To achieve the invention purpose of the present invention, the technical solution provided by the present invention is as follows:

[0006] A method for detecting scratches on the surface of a bearing based on machine vision, comprising the following steps:

[0007] Step 1: Use an industrial camera in cooperation with an industrial lens and a coaxial light source to collect bearing images and obtain a bearing surface image dataset.

[0008] Step 2: Extract the region of interest of the image to obtain a bearing ring image, and perform data annotation on the image to make a scratch detection dataset.

[0009] Step 3: Unfold the bearing ring image into a rectangle, convert the characters distributed on the ring into a horizontal distribution, and create a character recognition dataset.

[0010] Step 4: Build a bearing surface scratch detection network model, and use the scratch detection dataset in Step 2 to train the scratch detection network model.

[0011] Step 5: Use the character recognition dataset in Step 3 to train the CRNN character recognition network model, and implement character recognition based on PaddleOCR.

[0012] Step 6: Image prediction. If a scratch is detected in the bearing image, it is determined that the bearing is unqualified, and the scratch position is visualized; if no scratch is detected in the bearing image, it is determined that the bearing is qualified, and the model number of the qualified bearing is output.

[0013] Preferably, the specific method for using an industrial camera in cooperation with an industrial lens and a coaxial light source to collect bearing images and obtain a bearing surface image dataset in Step 1 is as follows: Collect qualified bearings and unqualified bearings with scratches on the surface from the industrial site, build an experimental platform, use an industrial camera and a supporting industrial lens and coaxial light source to collect bearing surface images. The collected images are 2448*2048 RGB color images. Crop the edge part of the original image, and the size after cropping is 2048*2048. Uniformly scale the cropped images, and the size of the processed images is 640*640. The size of the images input to the neural network is 640*640.

[0014] Preferably, the specific method for extracting the region of interest of the image and obtaining the bearing ring image in Step 2 is as follows: Use the gradient-based Hough transform to detect the ring. Since the inner and outer circles of the bearing are concentric circles, but the traditional Hough gradient method can only detect the circle with a smaller radius in the concentric circles and cannot detect the circle with a larger radius. The present invention uses the quadratic Hough gradient method to detect the concentric circles in the image. The first Hough gradient detection: Convert the color RGB image into a grayscale image, use the Canny edge detection operator to obtain the edge image information, and at the same time obtain the gradient information of each pixel point. Through the Hough transform, the accumulation of the gradient direction is performed in the parameter space, and the local peak of the accumulation is the center of the circle. Traverse all edge points again, and determine the smaller radius r1 of the circle by accumulating the local radius peak. The second Hough gradient detection: Given that the radius detected in the first Hough detection is r1, set all pixel values within the circle with a radius of r1+10 to 0, and perform the Hough transform again to obtain the radius r2 of the larger circle. So far, two concentric circles are detected, and the middle ring area is the region of interest of the image.

[0015] Preferably, the production of the bearing scratch detection data set described in step 2 includes: annotating the collected images. When there are scratches on the bearing, use a rectangular box to annotate the position where the scratches are located. The annotated images generate corresponding text files, and the file content includes the image category, the width w of the rectangular box, the height h of the rectangular box, and the coordinates (x, y) of the center point of the rectangular box. When there are no scratches on the bearing surface, do not annotate the image. The data set is divided in the ratio of training set: validation set: test set = 8:1:1.

[0016] Preferably, the specific steps of unfolding the bearing ring image into a rectangle and converting the characters distributed on the ring into a horizontal distribution described in step 3 are as follows: use the conversion formula between polar coordinates and rectangular coordinates to unfold the ring bearing into a rectangle.

[0017] x = ρcosθ

[0018] y = ρsinθ

[0019] where (x, y) are the coordinates of a certain point on the ring converted to the rectangular coordinate system, ρ is the polar radius of the point in the polar coordinate system, and θ is the polar angle of the point in the polar coordinate system.

[0020] Preferably, for the production of the character recognition data set described in step 3, intercept the character area on the rectangular bearing image, and the image file name consists of the bearing model and the suffix name. The data set is divided in the ratio of training set: validation set: test set = 8:1:1.

[0021] Preferably, the construction of the bearing surface scratch detection network model described in step 4 includes: improving the target detection network model based on YOLOv5: adding a convolutional attention mechanism - CBAM module after the backbone network and before the bottleneck layer. The position regression loss function of the target detection network uses the EIOU loss, the detection head uses a decoupled head, and the detection box prediction regression parameters use an anchor-free mechanism.

[0022] Preferably, the backbone network is of the CSPDarknet53 structure. Darknet53 is a 53-layer deep neural network, stacked by residual modules in the ratio of 3:6:9:3. The CSP structure divides the input into two branches. One branch first passes through the CBL module, then passes through n Bottleneck layers, and after the Bottleneck layer, a convolution operation is performed. The other branch directly performs convolution. The feature maps obtained from the two branches are concatenated, and a non-linear transformation is performed through the SiLU activation function, and finally, the output is obtained through the CBL module. The CBL module includes convolution, batch normalization, and the SiLU activation function. The Bottleneck layer includes a residual connection composed of a 1*1 convolution and a 3*3 convolution.

[0023] Preferably, a convolutional attention mechanism - CBAM module is added to the target detection network. The CBAM module consists of a channel attention mechanism and a spatial attention module mechanism. The channel attention mechanism performs maximum pooling and average pooling operations on the feature map in the channel dimension, sends the obtained feature map into a shared fully connected layer, and successively performs addition and sigmoid activation operations to generate a channel attention mechanism map. The input of the spatial attention mechanism is the output feature map of the above channel attention mechanism. Global pooling and average pooling operations are performed in the spatial dimension to obtain a one-channel feature map respectively. The two feature maps are concatenated in the channel dimension, and finally, a convolutional attention mechanism feature map is obtained through convolution and sigmoid activation.

[0024] Preferably, the target detection network adopts an EIOU loss function. The EIOU loss is an improvement on the CIOU loss, replacing the aspect ratio loss with a width-height loss. The formula for the EIOU loss function is:

[0025]

[0026] where: IOU is the ratio of the intersection to the union of the predicted box and the ground truth box, ρ(b, b gt ) represents the Euclidean distance between the center points of the predicted box and the ground truth box, b represents the center point of the predicted box, b gt represents the center point of the ground truth box, c represents the diagonal distance of the smallest bounding rectangle that can just contain the predicted box and the ground truth box; ρ(w, w gt ) represents the difference between the width of the predicted box and the width of the ground truth box, w represents the width of the predicted box, w gt represents the width of the ground truth box, C w represents the width of the smallest bounding rectangle that can just contain the predicted box and the ground truth box; ρ(h, h gt ) represents the difference between the height of the predicted box and the height of the ground truth box, h represents the height of the predicted box, h gt represents the height of the ground truth box, C h represents the height of the smallest bounding rectangle that can just contain the predicted box and the ground truth box.

[0027] Preferably, considering the scratch features, some scratches belong to small targets. The small target is defined as the ratio of the width and height of the target bounding box to the width and height of the image being less than 0.1, or the ratio of the area of the target bounding box to the area of the image being less than 0.03. An anchor-free mechanism is introduced into the YOLOv5 detection head, and the coupled state of target classification prediction, target box position parameter prediction, and target confidence prediction is changed to a decoupled state, and the three detection head parameters are not shared. The anchor-free mechanism means that the network does not preset an Anchor template, and directly generates four parameters of the predicted rectangular box during prediction. The specific formula is:

[0028] x center = cx +t x

[0029] y center = c y +t y

[0030]

[0031]

[0032] where (x center , y center ) is the center point of the prediction box, (c x , c y ) is the upper left corner coordinates of the grid where the center point of the prediction box is located, (t x , t y ) is the offset of the center point of the prediction box relative to the upper left corner point of the current grid where it is located, are the width and height of the prediction box respectively.

[0033] Preferably, the training of the scratch detection network model in step 4 is specifically as follows: The data augmentation is divided into three steps. First, the image is filtered, then the histogram is equalized, and finally the HSV enhancement strategy is used to change the hue, saturation, and brightness of the image. The strategies adopted during network training include multi-scale training, and the multi-scale training means that the actual training image is 0.5 - 1.5 times the original input image. In the initial stage of training, the Warmup training method is adopted, and the learning rate is gradually increased. Mixed precision training is used to accelerate the convergence of the network. After the training is completed, the training model with the best prediction effect is saved.

[0034] Preferably, step 5: Use the character recognition dataset in step 3 to train the CRNN character recognition network model. The specific implementation of character recognition based on PaddleOCR is as follows: The character recognition network model adopts the CRNN algorithm. CRNN is an algorithm based on CTC, mainly used for recognizing regular text, and the prediction speed is relatively fast. After the training is completed, the model with the best prediction effect is saved. Character detection uses the DBNet network model. The detection model DBNet is cascaded with the trained character recognition model CRNN, and the character position is detected and recognized based on PaddleOCR.

[0035] Preferably, step 6: Image prediction. If a scratch is detected on the bearing image, it is determined that the bearing is unqualified, and the position of the scratch is visualized; if no scratch is detected on the bearing image, it is determined that the bearing is qualified, and the model number of the qualified bearing is output. Considering the actual application in the industrial field, the bearing is placed on the conveyor belt. After reaching the designated position, the industrial camera captures the surface image of the bearing and performs program processing. The program processing steps mainly include: inputting the image into the bearing surface scratch detection network. If a scratch is detected, the program outputs "unqualified" and visualizes the scratch position of the bearing; if no scratch is detected, the bearing image is continuously sent to the character recognition network, the program outputs "qualified", and the character information, that is, the model number of the bearing, is output.

[0036] Compared with the prior art, the beneficial effects of the present invention are:

[0037] 1. In the image preprocessing part, the Hough transform is used to detect the region of interest in the image. Compared with directly inputting the entire image, the image processing range is reduced, and the program operation efficiency is improved.

[0038] 2. Using polar coordinate transformation, the ring bearing is unfolded into a rectangle, avoiding ambiguous characters existing in directly detecting the ring region, and improving the network detection accuracy.

[0039] 3. The attention mechanism is added to the target detection network to quickly locate the region of interest of the scratch and suppress useless information. The EIOU loss function is used to make the convergence speed of the network faster. The anchor-free mechanism is used to reduce the parameters that the network needs to learn and improve the recall rate of the network for small target detection.

[0040] 4. The present invention improves the accuracy of bearing scratch detection, accurately outputs the model number of the scratch-free bearing, improves the degree of automation detection in the industrial field, and reduces the manufacturing cost of enterprises. Description of the Drawings

[0041] Figure 1 is the step flow chart of the present invention;

[0042] Figure 2(a) is the surface image of the bearing with scratches;

[0043] Figure 2(b) is the image of the region of interest of the bearing extracted after the Hough transform;

[0044] Figure 3(a) is the surface image of the qualified bearing without scratches;

[0045] Figure 3(b) is the bearing image after polar coordinate transformation;

[0046] Figure 4 is the structure diagram of the scratch detection network of the present invention;

[0047] Figure 5 is the structure diagram of the CBL module network;

[0048] Figure 6 It is the network structure diagram of the C3 module;

[0049] Figure 7(a) is the network structure diagram of the BottleNeck1 module;

[0050] Figure 7(b) is the network structure diagram of the BottleNeck2 module;

[0051] Figure 8 It is the network structure diagram of the SPPF module;

[0052] Figure 9 It is the network structure diagram of the detection head Head module;

[0053] Figure 10 It is the program flow chart of image prediction;

[0054] Figure 11 It is the detection effect diagram of the scratch on the bearing surface;

[0055] Figure 12 It is the recognition effect diagram of the bearing model characters. Specific implementation manners

[0056] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings.

[0057] As Figure 1 shown, a method for detecting scratches on the bearing surface based on machine vision includes the following steps:

[0058] Step 1: Use an industrial camera in cooperation with an industrial lens and a coaxial light source to collect bearing images and obtain a bearing surface image dataset.

[0059] Collect qualified bearings and unqualified bearings with scratches on the surface from the industrial site and build an experimental platform. Use an industrial camera and supporting industrial lens and coaxial light source to collect bearing surface images. The collected images are 2448*2048 RGB color images. Crop the edge part of the original image, and the cropped size is 2048*2048. Uniformly scale the cropped image, and the processed image size is 640*640. The image size input to the neural network is 640*640.

[0060] Step 2: Extract the region of interest in the original image to obtain a bearing ring image, perform data annotation on the image, and make a scratch detection dataset.

[0061] As shown in Figure 2(a), it is the bearing image acquired by the industrial camera. As shown in Figure 2(b), it is the interested circular ring area after using the Hough transform. Since the inner and outer circles of the bearing are concentric circles, but the traditional Hough gradient method can only detect the circle with a smaller radius among the concentric circles and cannot detect the circle with a larger radius. The present invention uses the quadratic Hough gradient method to detect the concentric circles in the image. The first Hough gradient detection: Convert the color RGB image into a grayscale image, use the Canny edge detection operator to obtain the edge image information, and at the same time obtain the gradient information of each pixel point. Through the Hough transform, the accumulation of the gradient direction is carried out in the parameter space, and the local peak value of the accumulation is the center of the circle. Traverse all the edge points again, and determine the smaller radius r1 of the circle by accumulating the local radius peak value. The second Hough gradient detection: Given that the radius detected in the first Hough detection is r1, set all the pixel values within the circle with a radius of r1 + 10 to 0, and perform the Hough transform again to obtain the radius r2 of the larger circle. Thus, the two concentric circles are detected, and the middle circular ring area is the interested area of the image.

[0062] Annotate the acquired image. When there are scratches on the bearing, use a rectangular box to annotate the position where the scratches are located. After the annotation is completed, a corresponding text file is generated for the image. The file content includes the image category, the width w of the rectangular box, the height h of the rectangular box, and the coordinates (x, y) of the center point of the rectangular box. When there are no scratches on the bearing surface, do not annotate the image. The dataset is divided in the ratio of training set: validation set: test set = 8:1:1.

[0063] Step 3: Unroll the bearing circular ring image into a rectangle, and the characters distributed on the circular ring are converted into a horizontal distribution. As shown in Figure 3(a), it is the original image. Use the conversion formula between polar coordinates and rectangular coordinates to unroll the circular ring bearing into a rectangle, as shown in Figure 3(b). The conversion formula is:

[0064] x = ρcosθ

[0065] y = ρsinθ

[0066] Where (x, y) is the coordinate of a certain point on the circular ring converted to the rectangular coordinate system, ρ is the polar radius of this point in the polar coordinate system, and θ is the polar angle of this point in the polar coordinate system. Make a character recognition dataset. Crop the character area from the bearing image unrolled into a rectangle. The image file name consists of the bearing model and the suffix name. The dataset is divided in the ratio of training set: validation set: test set = 8:1:1.

[0067] Step 4: Build the bearing surface scratch detection network model, and use the data labeled in Step 2 to train the scratch detection network model.

[0068] Build the bearing surface scratch detection network model. The model structure diagram is as Figure 4As shown in the figure. The object detection network model based on YOLOv5 is improved as follows: After the backbone network and before the bottleneck layer, a convolutional attention mechanism - CBAM module is added. The position regression loss function of the object detection network uses the EIOU loss. The detection head uses a decoupled head, and the detection box prediction regression parameters use an anchor - free mechanism. The backbone network is of the CSPDarknet53 structure. Darknet53 is a 53 - layer deep neural network, stacked by residual modules in a ratio of 3:6:9:3. The CSP structure divides the input into two branches. One branch first passes through the CBL module, then through n Bottleneck layers with residual connections. After the Bottleneck layer, a convolutional operation is performed. The other branch directly performs convolution. The feature maps obtained from the two branches are concatenated, and a non - linear transformation is performed through the SiLU activation function. Finally, the output is obtained through the CBL module. The CBL module includes convolution, batch normalization, and the SiLU activation function, as Figure 5 shown. As Figure 6 shown in Figure Figure 6 is the C3 module, which contains 3 convolutional modules and the Bottleneck layer. The Bottleneck layer with residual connection is a residual connection composed of 1*1 convolution and 3*3 convolution, as shown in Figure 7(a). Figure 7(b) shows the Bottleneck layer without residual connection

[0069] The convolutional attention mechanism - CBAM module is composed of a channel attention mechanism and a spatial attention module mechanism. The channel attention mechanism performs max - pooling and average - pooling operations on the feature map in the channel dimension. The obtained feature map is fed into a shared fully - connected layer, followed by addition and sigmoid activation operations in sequence to generate the channel attention mechanism map. The input of the spatial attention mechanism is the output feature map of the above - mentioned channel attention mechanism. Global pooling and average - pooling operations are performed in the spatial dimension to obtain a one - channel feature map respectively. The two feature maps are concatenated in the channel dimension, and finally, the convolutional attention mechanism feature map is obtained through convolution and sigmoid activation. After the CBAM module is the SPPF module, which can better achieve feature fusion, as Figure 8 shown in Figure Figure 8 is the SPPF module. The EIOU loss is an improvement on the CIOU loss, replacing the aspect ratio loss with the width - height loss. The formula of the EIOU loss function is:

[0070]

[0071] where: IOU is the ratio of the intersection to the union of the predicted box and the ground - truth box, ρ(b, b gt ) represents the Euclidean distance between the center points of the predicted box and the ground - truth box, b represents the center point of the predicted box, b gt represents the center point of the ground - truth box, c represents the diagonal distance of the smallest bounding rectangle that can just contain the predicted box and the ground - truth box; ρ(w, wgt ) represents the difference between the width of the predicted bounding box and the width of the ground truth bounding box. w represents the width of the predicted bounding box, and w gt represents the width of the ground truth bounding box, and C w represents the width of the smallest enclosing rectangle that can just contain the predicted bounding box and the ground truth bounding box; ρ(h, h gt ) represents the difference between the height of the predicted bounding box and the height of the ground truth bounding box. h represents the height of the predicted bounding box, and h gt represents the height of the ground truth bounding box, and C h represents the height of the smallest enclosing rectangle that can just contain the predicted bounding box and the ground truth bounding box.

[0072] Some scratches belong to small targets. The small target is defined as the ratio of the width and height of the target bounding box to the width and height of the image being less than 0.1, or the ratio of the area of the target bounding box to the area of the image being less than 0.03. The anchor-free mechanism is introduced into the YOLOv5 detection head, and the coupled state of target classification prediction, target box position parameter prediction, and target confidence prediction is changed to a decoupled state, and the three detection head parameters are not shared. The anchor-free mechanism means that the network does not pre-set the Anchor template, and directly generates the four parameters of the predicted rectangle box during prediction. The specific formula is:

[0073] x center = c x + t x

[0074] y center = c y + t y

[0075]

[0076]

[0077] where (x center , y center ) is the center point of the predicted bounding box, (c x , c y ) is the upper left corner coordinate of the grid where the center point of the predicted bounding box is located, and (t x , t y ) is the offset of the center point of the predicted bounding box relative to the upper left corner point of the current grid, are the width and height of the predicted bounding box respectively. As Figure 9 shown is the improved detection head.

[0078] Data augmentation is divided into three steps. First, the image is filtered. Then, histogram equalization is performed. Finally, the HSV enhancement strategy is used to change the hue, saturation, and brightness of the image. The strategies adopted during network training include multi-scale training. In multi-scale training, the actual training image is 0.5 - 1.5 times the original input image. In the initial stage of training, the Warmup training method is used to gradually increase the learning rate, and mixed-precision training is used to accelerate the convergence of the network. After the training is completed, the training model with the best prediction effect is saved.

[0079] Step 5: Use the image obtained in Step 3 to train the CRNN character recognition network model, and implement character recognition based on PaddleOCR.

[0080] The character recognition network model adopts the CRNN algorithm. CRNN is mainly used to recognize regular text. CRNN is an algorithm based on CTC, and its prediction speed is relatively fast. After the training is completed, the model with the best prediction effect is saved. For character detection, the DBNet network model is used. The detection model DBNet is cascaded with the trained character recognition model CRNN, and character position detection and recognition are performed based on PaddleOCR.

[0081] Step 6: Image prediction. If a scratch is detected on the bearing image, it is determined that the bearing is unqualified, and the scratch position is visualized. If no scratch is detected on the bearing image, it is determined that the bearing is qualified, and the model number of the qualified bearing is output.

[0082] As Figure 10 shown in the detection flow chart, considering the actual application in the industrial field, the bearing is placed on the conveyor belt. After reaching the specified position, the industrial camera takes an image of the bearing surface and performs program processing. The program processing steps mainly include: inputting the image into the bearing surface scratch detection network. If a scratch is detected, the program outputs "unqualified" and visualizes the scratch position of the bearing, as Figure 11 shown in the detection effect diagram of the bearing surface scratch; if no scratch is detected, the bearing image is continuously sent to the character recognition network. The program outputs "qualified" and outputs the character information, that is, the model number of the bearing, as Figure 12 shown in the character recognition effect diagram of the bearing model number.

[0083] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for detecting scratches on the surface of a bearing based on machine vision, characterized in that, it includes the following steps: Step 1: Use an industrial camera in cooperation with an industrial lens and a coaxial light source to collect bearing images and obtain a bearing surface image dataset; Step 2: Extract the region of interest in the image to obtain a bearing ring image, perform data annotation on the image, and make a scratch detection dataset; In the said Step 2, the specific steps of extracting the region of interest in the image to obtain a bearing ring image are: Use the Hough transform based on gradient to detect the ring, specifically use the quadratic Hough gradient method to detect concentric circles in the image, including: The first Hough gradient detection: Convert the color RGB image into a grayscale image, use the Canny edge detection operator to obtain the edge image information, and at the same time obtain the gradient information of each pixel point; Through the Hough transform, perform the accumulation of the gradient direction in the parameter space, and the local peak of the accumulation is the center of the circle; Traverse all edge points again, and determine the smaller radius r1 of the circle by accumulating the local radius peak; The second Hough gradient detection: Given that the radius detected in the first Hough detection is r1, set all pixel values within the circle with a radius of r1 + 10 to 0, and perform the Hough transform again to obtain the radius r2 of the larger circle; So far, two concentric circles are detected, and the middle ring area is the region of interest in the image; Step 3: Unroll the bearing ring image into a rectangle, convert the characters distributed on the ring into a horizontal distribution, and make a character recognition dataset; Step 4: Build a bearing surface scratch detection network model, and use the scratch detection dataset in Step 2 to train the scratch detection network model; In the said Step 4, the building of the bearing surface scratch detection network model includes: Improve the object detection network model based on YOLOv5: Add a convolutional attention mechanism - CBAM module after the backbone network and before the bottleneck layer, the position regression loss function of the object detection network uses the EIoU loss, the detection head uses a decoupled head, and the detection box prediction regression parameters use an anchor-free mechanism; The object detection network uses the EIOU loss function, and the EIOU loss is improved on the basis of the CIOU loss, replacing the aspect ratio loss with the width and height loss. The formula of the EIOU loss function is: Among them: IOU is the ratio of the intersection to the union of the predicted box and the ground truth box, ρ(b, b gt ) represents the Euclidean distance between the centers of the predicted box and the ground truth box, b represents the center point of the predicted box, and b gt represents the center point of the ground truth box, c represents the diagonal distance of the smallest bounding rectangle that can just contain the predicted box and the ground truth box; ρ(w, w gt ) represents the difference between the width of the predicted box and the width of the ground truth box, w represents the width of the predicted box, and w gt represents the width of the ground truth box, and C w represents the width of the smallest bounding rectangle that can just contain the predicted box and the ground truth box; ρ(h, h gt ) represents the difference between the height of the predicted box and the height of the ground truth box, h represents the height of the predicted box, and h gt represents the height of the ground truth box, and C h represents the height of the smallest bounding rectangle that can just contain the predicted box and the ground truth box; Set some scratches as small targets, and the small target is that the ratio of the width and height of the target bounding box to the width and height of the image is less than 0.1, or the ratio of the area of the target bounding box to the area of the image is less than 0.03; Introduce the anchor-free box mechanism into the YOLOv5 detection head, and change the coupled state of the target classification prediction, the target box position parameter prediction, and the confidence prediction of whether it is a target to a decoupled state, and the three detection head parameters are not shared; The anchor-free mechanism is that the network does not preset the Anchor template, and directly generates the four parameters of the prediction rectangle box during prediction. The specific formula is: x center = c x + t x y center = c y + t y where (x center , y center ) is the center point of the prediction box, (c x , c y ) is the upper left corner coordinates of the grid where the center point of the prediction box is located, (t x , t y ) is the offset of the center point of the prediction box relative to the upper left corner point of the current grid, are the width and height of the prediction box respectively; Step 5: Use the character recognition dataset in Step 3 to train the CRNN character recognition network model and implement character recognition based on PaddleOCR; Step 6: Image prediction. If a scratch is detected in the bearing image, it is determined that the bearing is unqualified, and the position of the scratch is visualized; if no scratch is detected in the bearing image, it is determined that the bearing is qualified, and the model number of the qualified bearing is output.

2. A method for detecting bearing surface scratches based on machine vision according to claim 1, wherein, in the specific step 1: collect qualified bearings and unqualified bearings with scratches on the surface from the industrial site, and build an experimental platform. Use an industrial camera, a supporting industrial lens, and a coaxial light source to collect the surface image of the bearing. The collected image is a 2448*2048 RGB color image; crop the edge part of the original image, and the size after cropping is 2048*2048; perform a unified scaling process on the cropped image, and the size of the processed image is 640*640. The size of the image input to the neural network is 640*640.

3. A method for detecting bearing surface scratches based on machine vision according to claim 1, wherein, in the specific step 2 of making the bearing scratch detection data set: first, annotate the collected images. When there is a scratch on the bearing, use a rectangular box to mark the position where the scratch is located. After the annotation is completed, a corresponding text file is generated for the image. The file content includes the image category, the width w of the rectangular box, the height h of the rectangular box, and the coordinates (x, y) of the center point of the rectangular box; when there is no scratch on the bearing surface, this image is not annotated; among them, the scratch detection data set is divided in the ratio of training set: validation set: test set = 8:1:

1.

4. A method for detecting bearing surface scratches based on machine vision according to claim 1, wherein, in the specific step 3 of unfolding the bearing ring image into a rectangle and converting the characters distributed on the ring into a horizontal distribution: use the conversion formula of polar coordinates and rectangular coordinates to unfold the ring bearing into a rectangle. x = ρcosθ y = ρsinθ where (x, y) are the coordinates of the point on the ring converted to the rectangular coordinate system, ρ is the polar radius of the point in the polar coordinate system, and θ is the polar angle of the point in the polar coordinate system.

5. A method for detecting bearing surface scratches based on machine vision according to claim 1, wherein, in the specific step 3 of making the character recognition data set: intercept the character area on the rectangular bearing image, and the image file name consists of the bearing model number and the suffix name; the character recognition data set is divided in the ratio of training set: validation set: test set = 8:1:

1.

6. A method for detecting bearing surface scratches based on machine vision according to claim 1, wherein, The backbone network is the CSPDarknet53 structure. Darknet53 is a 53-layer deep neural network stacked by residual modules in a ratio of 3:6:9:

3. The CSP structure divides the input into two branches. One branch first passes through the CBL module, then through n Bottleneck layers, followed by a convolution operation after the Bottleneck layers. The other branch directly performs convolution. The feature maps obtained from the two branches are concatenated, subjected to a non-linear transformation through the SiLU activation function, and finally output through the CBL module. The CBL module includes convolution, batch normalization, and the SiLU activation function. The Bottleneck layer includes a residual connection composed of a 1*1 convolution and a 3*3 convolution.

7. A method for detecting scratches on the surface of a bearing based on machine vision according to claim 1, characterized in that, a convolutional attention mechanism - CBAM module is added to the object detection network. The CBAM module is composed of a channel attention mechanism and a spatial attention module mechanism. Among them, the channel attention mechanism performs maximum pooling and average pooling operations on the feature map in the channel dimension, sends the obtained feature map into a shared fully connected layer, and successively passes through an addition operation and a sigmoid activation operation to generate a channel attention mechanism map. The input of the spatial attention mechanism is the output feature map of the above channel attention mechanism. Global pooling and average pooling operations are performed in the spatial dimension to obtain a one-channel feature map respectively. The two feature maps are concatenated in the channel dimension, and finally a convolutional attention mechanism feature map is obtained through convolution and sigmoid activation.

8. A method for detecting scratches on the surface of a bearing based on machine vision according to claim 1, characterized in that, the training of the scratch detection network model in step 4 is specifically as follows: data augmentation is divided into three steps. First, the image is filtered, then the histogram is equalized, and finally the HSV enhancement strategy is used to change the hue, saturation, and brightness of the image. The strategy adopted during network training is multi-scale training. The multi-scale training means that the actual training image is 0.5 - 1.5 times the original input image. In the initial stage of training, the Warmup training method is adopted, and the learning rate is gradually increased. Mixed precision training is used to accelerate the convergence of the network; After training, the training model with the best prediction effect is saved.

9. A method for detecting scratches on the surface of a bearing based on machine vision according to claim 1, characterized in that, in step 5, specifically: the character recognition network model adopts the CRNN algorithm, and the model with the best prediction effect is saved after training; character detection adopts the DBNet network model. The detection model DBNet is cascaded with the trained character recognition model CRNN, and the detection and recognition of character positions are based on PaddleOCR.

Citation Information

Patent Citations

  • Bearing steel ball part detection method based on machine vision

    CN111815575A

  • Defect inspection device, defect inspection method, defect inspection program and recording medium

    JP2015055580A