A method for detecting rack defects based on machine vision

The rack defect detection method using machine vision and dual CNN networks addresses the high cost and real-time limitations of manual inspections by enhancing contours and integrating neural networks to accurately identify defects in rack images.

CN118781123BActive Publication Date: 2024-12-06SICHUAN VOCATIONAL & TECHN COLLEGE OF COMM +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411274797.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-12-06
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

Existing manual inspection methods for rack railways are costly and unable to detect defects in real time, posing safety risks due to the inability to promptly identify issues.

Method used

A rack defect detection method using machine vision that involves contour enhancement, dual CNN feature fusion neural networks, and image processing techniques to accurately identify defects in rack images.

Benefits of technology

Improves defect detection accuracy and reduces costs by enhancing contour features, compressing unnecessary information, and integrating multiple neural network outputs to predict rack defects efficiently.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118781123B_ABST
    Figure CN118781123B_ABST
Patent Text Reader

Abstract

The invention discloses a rack defect detection method based on machine vision, which belongs to the technical field of image processing. After collecting a rack image, the invention performs contour enhancement on the rack image to obtain a first contour enhanced image and a second contour enhanced image, respectively extracts the regional maximum pixel value and the pixel mean of the two contour enhanced images, constructs a contour compression image, realizes the extraction of key features, and compresses non-key features. A dual CNN feature fusion neural network can be used to effectively combine the features of the first contour compression image and the second contour compression image, thereby improving the accuracy and robustness of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a rack defect detection method based on machine vision. Background Art

[0002] Cog railways are an ingenious engineering solution to overcome the limitations of conventional wheel-rail railways when climbing steep terrain. In this system, in addition to the regular smooth track, a central track with teeth is added. The trains are equipped with gears that match these teeth and when the train travels on the slope, these gears will tightly engage the cogs to provide additional traction and stability.

[0003] This design allows trains to travel on very steep slopes, even up to staggering slopes of 48% or more. This is because the meshing of the gear and the rack provides a stronger grip than ordinary wheel-rail adhesion, reducing the risk of slipping. As a result, rack railways are a common mode of transportation in mountainous areas, mountain towns, and tourist attractions, especially in areas with complex terrain and steep slopes. Existing defect detection of rack railways mainly relies on manual inspections of rack railways. Routine inspections are used to check for defects in the racks to ensure the safety of the rack railways. However, the manual inspection method has the problems of high detection costs and the inability to detect in real time. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a rack defect detection method based on machine vision, which solves the problems of the existing manual rack detection, such as high detection cost and inability to detect in real time.

[0005] In order to achieve the above-mentioned object of the invention, the technical solution adopted by the present invention is: a rack defect detection method based on machine vision, comprising the following steps:

[0006] S1, collecting a rack image, and performing contour enhancement on the rack image to obtain a first contour enhanced image and a second contour enhanced image;

[0007] S2, constructing a first contour compressed image according to the maximum pixel value and the pixel mean value of each area on the first contour enhanced image;

[0008] S3, constructing a second contour compressed image according to the maximum pixel value and the pixel mean value of each area on the second contour enhanced image;

[0009] S4. Use a dual CNN feature fusion neural network to process the first contour compression image and the second contour compression image to obtain the rack defect position.

[0010] The beneficial effects of the present invention are:

[0011] 1. After collecting the rack image, the present invention performs contour enhancement on the rack image to obtain a first contour enhanced image and a second contour enhanced image, respectively extracts the regional maximum pixel value and the pixel mean of the two contour enhanced images, constructs a contour compression image, extracts key features, and compresses non-key features. The dual CNN feature fusion neural network can effectively combine the features of the first contour compression image and the second contour compression image to improve the accuracy and robustness of defect detection. The present invention collects rack images and detects defects on the rack images, thereby solving the problem of high detection cost and inability to detect in real time in the existing manual detection of racks.

[0012] 2. The present invention can more clearly highlight the contour and defect features of the rack by performing contour enhancement on the rack image, thereby improving the accuracy of subsequent defect detection.

[0013] 3. When constructing the contour compression image, the maximum pixel value and pixel mean of the region are used to help enhance the key features of the rack and compress unnecessary information, which can reduce the amount of calculation for subsequent processing.

[0014] Furthermore, the S1 comprises the following sub-steps:

[0015] S11, taking each pixel of the rack image as the center, calculating the first contour coefficient and the second contour coefficient of the central pixel;

[0016] S12, constructing a first contour enhanced image according to a first contour coefficient of a central pixel;

[0017] S13: construct a second contour enhanced image according to the second contour coefficient of the central pixel.

[0018] Furthermore, the formula for calculating the first contour coefficient of the central pixel in S11 is:

[0019] ,

[0020] Among them, d1 is the first contour coefficient of the central pixel, f (x-1,y+1) is the pixel value at position (x-1, y+1), f (x+1,y-1) is the pixel value at position (x+1, y-1), f (x+1,y+1) is the pixel value at position (x+1, y+1), f (x-1,y-1) is the pixel value at position (x-1, y-1), x is the horizontal coordinate of the center pixel, y is the vertical coordinate of the center pixel, and | | is the absolute value operation;

[0021] The formula for calculating the second contour coefficient of the central pixel in S11 is:

[0022] ,

[0023] Among them, d2 is the second contour coefficient of the central pixel, f (x,y+1) is the pixel value at position (x,y+1), f (x,y-1) is the pixel value at position (x, y-1), f (x-1,y) is the pixel value at position (x-1, y), f (x+1,y) is the pixel value at position (x+1,y).

[0024] The beneficial effect of the above-mentioned further scheme is as follows: the present invention calculates the first contour coefficient through the pixel values ​​at four positions (x-1, y+1), (x+1, y-1), (x+1, y+1) and (x-1, y-1), calculates the second contour coefficient through the four positions (x, y+1), (x, y-1), (x-1, y) and (x+1, y), constructs the first contour enhanced image through the first contour coefficient, and constructs the second contour enhanced image through the second contour coefficient, so that the first contour enhanced image and the second contour enhanced image fully characterize the contour features of the rack image.

[0025] Furthermore, the S12 comprises the following sub-steps:

[0026] S121, using the first contour coefficient as a new pixel value of the central pixel to obtain a first replacement image;

[0027] S122, removing pixels whose pixel values ​​in the first replacement image are less than a threshold value, to obtain a first contour image;

[0028] S123: Enhance the pixel values ​​on the first contour image to obtain a first contour enhanced image.

[0029] The beneficial effect of the above further scheme is: the present invention uses the first contour coefficient as the new pixel value of the central pixel point, and eliminates the pixel points whose pixel values ​​are less than the threshold value. The first contour coefficient of the present invention is the pixel distance in four directions around the center. The larger the first contour coefficient is, the more significant the contour feature is. Therefore, the pixel points greater than the threshold value are retained, the contour information is retained, the non-contour information is eliminated, and the pixel value is enhanced to improve the contour contrast.

[0030] Furthermore, the S13 comprises the following sub-steps:

[0031] S131, using the second contour coefficient as a new pixel value of the central pixel to obtain a second replacement image;

[0032] S132, removing pixels whose pixel values ​​in the second replacement image are less than a threshold value, to obtain a second contour image;

[0033] S133: Enhance the pixel values ​​on the second contour image to obtain a second contour enhanced image.

[0034] The beneficial effect of the above further scheme is: the present invention uses the second contour coefficient as the new pixel value of the central pixel point, and eliminates the pixel points whose pixel values ​​are less than the threshold value. The second contour coefficient of the present invention is the pixel distance in four directions around the center. The larger the second contour coefficient is, the more significant the contour feature is. Therefore, the pixel points greater than the threshold value are retained, the contour information is retained, the non-contour information is eliminated, and the pixel value is enhanced to improve the contour contrast.

[0035] The first contour coefficient and the second contour coefficient of the present invention are derived from pixel distances in different directions, and two contour enhanced images of the same rack image are obtained.

[0036] Furthermore, the formula for enhancing the pixel value in S123 and S133 is: en = [255 / (f max -f min )]•f, where f en is the enhanced pixel value, f max is the maximum pixel value, f min is the minimum pixel value, and f is the pixel value to be enhanced.

[0037] The beneficial effects of the above further scheme are: the maximum pixel value of the present invention is the maximum pixel value on the contour image, and the minimum pixel value is the minimum pixel value on the contour image. The present invention enhances the pixel values ​​in the contour image to improve the contrast between the various pixel values.

[0038] Furthermore, both S2 and S3 include the following sub-steps:

[0039] A1. Divide the contour enhanced image into multiple The area of ​​size, where L is a positive integer;

[0040] A2, extract the maximum pixel value and the pixel mean in each area, and calculate the weighted pixel value;

[0041] A3. Use the weighted pixel value as the new pixel value of the corresponding area to obtain a contour compressed image.

[0042] The beneficial effect of the above further solution is: the present invention divides the contour enhanced image into multiple In each area, the maximum pixel value and the pixel mean are extracted for weighted processing, which reduces the amount of data, extracts key features, and compresses the contour enhanced image. The area of ​​​​the original image is large and small, which reduces the amount of data without changing the shape of the overall outline.

[0043] Further, the dual CNN feature fusion neural network in S4 includes: a first CNN convolutional neural network, a second CNN convolutional neural network, a feature fusion unit, a first type of feature extraction unit, a second type of feature extraction unit, a first region generation network, a second region generation network and a defect output unit;

[0044] The input end of the first CNN convolutional neural network is used to input the first contour compression image; the input end of the second CNN convolutional neural network is used to input the second contour compression image; the input end of the feature fusion unit is respectively connected to the output end of the first CNN convolutional neural network and the output end of the second CNN convolutional neural network, and its output end is respectively connected to the input end of the first type of feature extraction unit and the input end of the second type of feature extraction unit; the input end of the first region generation network is connected to the output end of the first type of feature extraction unit; the input end of the second region generation network is connected to the output end of the second type of feature extraction unit; the input end of the defect output unit is respectively connected to the output end of the first region generation network and the output end of the second region generation network, and its output end is used to output the rack defect position; the defect output unit is used to take the intersection of the output of the first region generation network and the output of the second region generation network.

[0045] The beneficial effects of the above-mentioned further scheme are as follows: the present invention adopts a first CNN convolutional neural network to extract features of the first contour compression image, adopts a second CNN convolutional neural network to extract features of the second contour compression image, and then adopts a feature fusion unit to realize the fusion of the two features to obtain a fused feature, adopts a first type of feature extraction unit to further extract features from the fused feature to obtain a first type of feature, adopts a second type of feature extraction unit to further extract features from the fused feature to obtain a second type of feature, adopts a regional generation network respectively, and obtains respective defect target areas according to the first type of feature and the second type of feature, and the defect output unit integrates the outputs of the two region generation networks to obtain the rack defect position, thereby improving the accuracy of the rack defect position prediction.

[0046] Furthermore, the expression of the feature fusion unit is: , where X is the output of the feature fusion unit, H1 is the output of the first CNN convolutional neural network, and H2 is the output of the second CNN convolutional neural network. It is Hadamard.

[0047] Furthermore, the expression of the first type of feature extraction unit is:

[0048] ,

[0049] Among them, R1 is the first type of feature output by the first type of feature extraction unit, σ is the Sigmoid activation function, X is the output of the feature fusion unit, For Hadamard, for The convolutional layer;

[0050] The expression of the second type of feature extraction unit is:

[0051] ,

[0052] Among them, R2 is the second type of feature output by the second type of feature extraction unit, σ is the Sigmoid activation function, for The convolutional layer.

[0053] The beneficial effects of the above further solution are: the present invention adopts The convolutional layers and The convolutional layer obtains features of different scales, and according to the features of different scales, the activation function is used to obtain attention of different sizes. and , pay attention to the corresponding scale features and increase the attention of different scale features. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 is a flow chart of a rack defect detection method based on machine vision;

[0055] Figure 2 Schematic diagram of the structure of the dual CNN feature fusion neural network. DETAILED DESCRIPTION

[0056] The specific embodiments of the present invention are described to facilitate those skilled in the art to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the specific embodiments. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.

[0057] like Figure 1 As shown, a rack defect detection method based on machine vision includes the following steps:

[0058] S1, collecting a rack image, and performing contour enhancement on the rack image to obtain a first contour enhanced image and a second contour enhanced image;

[0059] S2, constructing a first contour compressed image according to the maximum pixel value and the pixel mean value of each area on the first contour enhanced image;

[0060] S3, constructing a second contour compressed image according to the maximum pixel value and the pixel mean value of each area on the second contour enhanced image;

[0061] S4. Use a dual CNN feature fusion neural network to process the first contour compression image and the second contour compression image to obtain the rack defect position.

[0062] The S1 comprises the following sub-steps:

[0063] S11, taking each pixel of the rack image as the center, calculating the first contour coefficient and the second contour coefficient of the central pixel;

[0064] S12, constructing a first contour enhanced image according to a first contour coefficient of a central pixel;

[0065] S13: construct a second contour enhanced image according to the second contour coefficient of the central pixel.

[0066] The formula for calculating the first contour coefficient of the central pixel in S11 is:

[0067] ,

[0068] Among them, d1 is the first contour coefficient of the central pixel, f (x-1,y+1) is the pixel value at position (x-1, y+1), f (x+1,y-1) is the pixel value at position (x+1, y-1), f (x+1,y+1) is the pixel value at position (x+1, y+1), f (x-1,y-1) is the pixel value at position (x-1, y-1), x is the horizontal coordinate of the center pixel, y is the vertical coordinate of the center pixel, and | | is the absolute value operation;

[0069] The formula for calculating the second contour coefficient of the central pixel in S11 is:

[0070] ,

[0071] Among them, d2 is the second contour coefficient of the central pixel, f (x,y+1) is the pixel value at position (x,y+1), f (x,y-1) is the pixel value at position (x, y-1), f (x-1,y) is the pixel value at position (x-1, y), f (x+1,y) is the pixel value at position (x+1,y).

[0072] The present invention calculates a first contour coefficient through pixel values ​​at four positions (x-1, y+1), (x+1, y-1), (x+1, y+1) and (x-1, y-1), calculates a second contour coefficient through four positions (x, y+1), (x, y-1), (x-1, y) and (x+1, y), constructs a first contour enhanced image through the first contour coefficient, and constructs a second contour enhanced image through the second contour coefficient, so that the first contour enhanced image and the second contour enhanced image fully characterize the contour features of the rack image.

[0073] The S12 comprises the following sub-steps:

[0074] S121, using the first contour coefficient as a new pixel value of the central pixel to obtain a first replacement image;

[0075] S122, removing pixels whose pixel values ​​in the first replacement image are less than a threshold value, to obtain a first contour image;

[0076] S123: Enhance the pixel values ​​on the first contour image to obtain a first contour enhanced image.

[0077] The present invention uses the first contour coefficient as the new pixel value of the central pixel point and eliminates the pixel points whose pixel values ​​are less than the threshold. The first contour coefficient of the present invention is the pixel distance in four directions around the center. The larger the first contour coefficient is, the more significant the contour feature is. Therefore, the pixel points greater than the threshold are retained, the contour information is retained, the non-contour information is eliminated, and the pixel value is enhanced to improve the contour contrast.

[0078] The S13 comprises the following sub-steps:

[0079] S131, using the second contour coefficient as a new pixel value of the central pixel to obtain a second replacement image;

[0080] S132, removing pixels whose pixel values ​​in the second replacement image are less than a threshold value, to obtain a second contour image;

[0081] S133: Enhance the pixel values ​​on the second contour image to obtain a second contour enhanced image.

[0082] In this embodiment, the threshold is set based on experiments and experience.

[0083] The present invention uses the second contour coefficient as the new pixel value of the central pixel point and eliminates the pixel points whose pixel values ​​are less than the threshold. The second contour coefficient of the present invention is the pixel distance in four directions around the center. The larger the second contour coefficient is, the more significant the contour feature is. Therefore, the pixel points greater than the threshold are retained, the contour information is retained, the non-contour information is eliminated, and the pixel value is enhanced to improve the contour contrast.

[0084] The first contour coefficient and the second contour coefficient of the present invention are derived from pixel distances in different directions, and two contour enhanced images of the same rack image are obtained.

[0085] The formula for enhancing the pixel value in S123 and S133 is: en = [255 / (f max -f min )]•f, where f en is the enhanced pixel value, f max is the maximum pixel value, f min is the minimum pixel value, and f is the pixel value to be enhanced.

[0086] The maximum pixel value of the present invention is the maximum pixel value on the contour image, and the minimum pixel value is the minimum pixel value on the contour image. The present invention enhances the contrast between the pixel values ​​by performing enhancement processing on the pixel values ​​in the contour image.

[0087] Both S2 and S3 include the following sub-steps:

[0088] A1. Divide the contour enhanced image into multiple The area of ​​size, where L is a positive integer;

[0089] A2, extract the maximum pixel value and the pixel mean in each area, and calculate the weighted pixel value;

[0090] In this embodiment, the formula for calculating the weighted pixel value is: p=ɑ1•p max +ɑ2•p min , where p is the weighted pixel value, p max is the maximum pixel value, p min is the minimum pixel value, ɑ1 is the first weighting coefficient, ɑ2 is the second weighting coefficient, ɑ1+ɑ2=1;

[0091] A3. Use the weighted pixel value as the new pixel value of the corresponding area to obtain a contour compressed image.

[0092] The present invention divides the contour enhanced image into multiple In each area, the maximum pixel value and the pixel mean are extracted for weighted processing, which reduces the amount of data, extracts key features, and compresses the contour enhanced image. The area of ​​​​the original image is large and small, which reduces the amount of data without changing the shape of the overall outline.

[0093] like Figure 2As shown, the dual CNN feature fusion neural network in S4 includes: a first CNN convolutional neural network, a second CNN convolutional neural network, a feature fusion unit, a first type of feature extraction unit, a second type of feature extraction unit, a first region generation network, a second region generation network and a defect output unit;

[0094] The input end of the first CNN convolutional neural network is used to input the first contour compression image; the input end of the second CNN convolutional neural network is used to input the second contour compression image; the input end of the feature fusion unit is respectively connected to the output end of the first CNN convolutional neural network and the output end of the second CNN convolutional neural network, and its output end is respectively connected to the input end of the first type of feature extraction unit and the input end of the second type of feature extraction unit; the input end of the first region generation network is connected to the output end of the first type of feature extraction unit; the input end of the second region generation network is connected to the output end of the second type of feature extraction unit; the input end of the defect output unit is respectively connected to the output end of the first region generation network and the output end of the second region generation network, and its output end is used to output the rack defect position; the defect output unit is used to take the intersection of the output of the first region generation network and the output of the second region generation network.

[0095] The present invention adopts a first CNN convolutional neural network to extract features of a first contour compression image, adopts a second CNN convolutional neural network to extract features of a second contour compression image, and then adopts a feature fusion unit to realize the fusion of the two features to obtain a fused feature, adopts a first type of feature extraction unit to further extract features from the fused feature to obtain a first type of feature, adopts a second type of feature extraction unit to further extract features from the fused feature to obtain a second type of feature, adopts a regional generation network respectively, obtains respective defect target regions according to the first type of feature and the second type of feature, and a defect output unit integrates the outputs of the two regional generation networks to obtain a rack defect position, thereby improving the accuracy of rack defect position prediction.

[0096] In this embodiment, the region generation network is an RPN region generation network.

[0097] In this embodiment, the loss function of the dual CNN feature fusion neural network can select an intersection-over-union function.

[0098] The expression of the feature fusion unit is: , where X is the output of the feature fusion unit, H1 is the output of the first CNN convolutional neural network, and H2 is the output of the second CNN convolutional neural network. It is Hadamard.

[0099] The expression of the first type of feature extraction unit is:

[0100] ,

[0101] Among them, R1 is the first type of feature output by the first type of feature extraction unit, σ is the Sigmoid activation function, X is the output of the feature fusion unit, For Hadamard, for The convolutional layer;

[0102] The expression of the second type of feature extraction unit is:

[0103] ,

[0104] Among them, R2 is the second type of feature output by the second type of feature extraction unit, σ is the Sigmoid activation function, for The convolutional layer.

[0105] The present invention adopts The convolutional layers and The convolutional layer obtains features of different scales, and according to the features of different scales, the activation function is used to obtain attention of different sizes. and , pay attention to the corresponding scale features and increase the attention of different scale features.

[0106] After the present invention collects the rack image, it performs contour enhancement on the rack image to obtain a first contour enhancement image and a second contour enhancement image, respectively extracts the regional maximum pixel value and the pixel mean of the two contour enhancement images, constructs a contour compression image, extracts key features, and compresses non-key features. The dual CNN feature fusion neural network can effectively combine the features of the first contour compression image and the second contour compression image to improve the accuracy and robustness of defect detection. The present invention collects the rack image and detects defects on the rack image, thereby solving the problem of high detection cost and inability to detect in real time in the existing manual detection of the rack.

[0107] The present invention can more clearly highlight the contour and defect features of the rack by performing contour enhancement on the rack image, thereby improving the accuracy of subsequent defect detection.

[0108] When constructing the contour compression image, the maximum pixel value and the pixel mean of the region are used to help enhance the key features of the rack and compress unnecessary information, which can reduce the computational complexity of subsequent processing.

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

Claims

1. A rack defect detection method based on machine vision, It is characterized in that The following steps are involved: S1, collecting a rack image, and performing contour enhancement on the rack image to obtain a first contour enhanced image and a second contour enhanced image; S2, constructing a first contour compressed image according to the maximum pixel value and the pixel mean value of each area on the first contour enhanced image; S3, constructing a second contour compressed image according to the maximum pixel value and the pixel mean value of each area on the second contour enhanced image; S4, using a dual CNN feature fusion neural network to process the first contour compression image and the second contour compression image to obtain the rack defect position; The dual CNN feature fusion neural network in S4 includes: a first CNN convolutional neural network, a second CNN convolutional neural network, a feature fusion unit, a first type of feature extraction unit, a second type of feature extraction unit, a first region generation network, a second region generation network and a defect output unit; The input end of the first CNN convolutional neural network is used to input the first contour compression image; the input end of the second CNN convolutional neural network is used to input the second contour compression image; the input end of the feature fusion unit is respectively connected to the output end of the first CNN convolutional neural network and the output end of the second CNN convolutional neural network, and its output end is respectively connected to the input end of the first type of feature extraction unit and the input end of the second type of feature extraction unit; the input end of the first region generation network is connected to the output end of the first type of feature extraction unit; the input end of the second region generation network is connected to the output end of the second type of feature extraction unit; the input end of the defect output unit is respectively connected to the output end of the first region generation network and the output end of the second region generation network, and its output end is used to output the rack defect position; the defect output unit is used to take the intersection of the output of the first region generation network and the output of the second region generation network.

2. The rack defect detection method based on machine vision according to claim 1, It is characterized in that The S1 comprises the following sub-steps: S11, taking each pixel of the rack image as the center, calculating the first contour coefficient and the second contour coefficient of the central pixel; S12, constructing a first contour enhanced image according to the first contour coefficient of the central pixel; S13: construct a second contour enhanced image according to the second contour coefficient of the central pixel.

3. The rack defect detection method based on machine vision according to claim 2, It is characterized in that The formula for calculating the first contour coefficient of the central pixel in S11 is: , Among them, d 1 is the first contour coefficient of the central pixel, f (x-1,y+1) is the pixel value at position (x-1, y+1), f (x+1,y-1) is the pixel value at position (x+1, y-1), f (x+1,y+1) is the pixel value at position (x+1, y+1), f (x-1,y-1) is the pixel value at position (x-1, y-1), x is the horizontal coordinate of the center pixel, y is the vertical coordinate of the center pixel, and | | is the absolute value operation; The formula for calculating the second contour coefficient of the central pixel in S11 is: , Among them, d 2 is the second contour coefficient of the central pixel, f (x,y+1) is the pixel value at position (x,y+1), f (x,y-1) is the pixel value at position (x, y-1), f (x-1,y) is the pixel value at position (x-1, y), f (x+1,y) is the pixel value at position (x+1,y).

4. The rack defect detection method based on machine vision according to claim 2, It is characterized in that The S12 comprises the following sub-steps: S121, using the first contour coefficient as a new pixel value of the central pixel to obtain a first replacement image; S122, removing pixels whose pixel values ​​in the first replacement image are less than a threshold value, to obtain a first contour image; S123: Enhance the pixel values ​​on the first contour image to obtain a first contour enhanced image.

5. The rack defect detection method based on machine vision according to claim 4, It is characterized in that The S13 comprises the following sub-steps: S131, using the second contour coefficient as a new pixel value of the central pixel to obtain a second replacement image; S132, removing pixels whose pixel values ​​in the second replacement image are less than a threshold value, to obtain a second contour image; S133: Enhance the pixel values ​​on the second contour image to obtain a second contour enhanced image.

6. The rack defect detection method based on machine vision according to claim 5, It is characterized in that The formula for enhancing the pixel value in S123 and S133 is: en = [255 / (f max -f min )]•f, where f en is the enhanced pixel value, f max is the maximum pixel value, f min is the minimum pixel value, and f is the pixel value to be enhanced.

7. The rack defect detection method based on machine vision according to claim 1, It is characterized in that Both S2 and S3 include the following sub-steps: A1. Divide the contour enhanced image into multiple The area of ​​size, where L is a positive integer; A2, extract the maximum pixel value and the pixel mean in each area, and calculate the weighted pixel value; A3. Use the weighted pixel value as the new pixel value of the corresponding area to obtain a contour compressed image.

8. The rack defect detection method based on machine vision according to claim 1, It is characterized in that The expression of the feature fusion unit is: , where X is the output of the feature fusion unit, H 1 is the output of the first CNN convolutional neural network, H 2 is the output of the second CNN convolutional neural network, It is Hadamard.

9. The rack defect detection method based on machine vision according to claim 1, It is characterized in that The expression of the first type of feature extraction unit is: , Among them, R 1 is the first type of feature output by the first type of feature extraction unit, σ is the Sigmoid activation function, X is the output of the feature fusion unit, For Hadamard, for The convolutional layer; The expression of the second type of feature extraction unit is: , Among them, R 2 is the second type of feature output by the second type of feature extraction unit, σ is the Sigmoid activation function, for The convolutional layer.