A method and system for visual inspection of gear appearance defects
By performing threshold segmentation and edge detection on grayscale images of gears, calculating feature values of connected regions, and distinguishing abnormal regions, the problem of low accuracy in gear defect detection in existing technologies is solved, and high-precision gear defect classification and status judgment are achieved.
Patent Information
- Application Number
- CN202410287013.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-13
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-03-13
AI Technical Summary
Existing technologies cannot effectively determine the type of gear abnormality, resulting in low accuracy of gear defect detection results and an inability to accurately judge the gear condition.
By acquiring grayscale images of gears, threshold segmentation and edge detection are performed to extract edge lines, calculate the regional integrity feature values of connected regions, distinguish independent and continuous abnormal regions, and detect gear appearance defects.
It improves the accuracy of gear defect detection, enables accurate judgment of gear condition, and provides reference information for gear repair and disposal.
Smart Images

Figure CN118196025B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image analysis, and in particular to a method and system for visually detecting appearance defects of gears. Background Art
[0002] Gears are a mechanical device and one of the most important components in many mechanical systems. They can transmit power through the meshing of gear teeth. If there are defects in the gear tooth shape, the gear will get stuck when rotating, causing instability in the transmission system, increased noise and other problems, causing damage to mechanical equipment.
[0003] However, different abnormalities may occur during the production process of gears, and different types of residual teeth have different effects on gear defects and require different treatment methods. When performing defect detection on the appearance of gears, the prior art usually determines whether the gear has residual teeth based on the shape of the gear teeth. This fails to effectively determine the type of abnormality of the gear and is difficult to fully reflect the actual condition of the gear, resulting in low accuracy of the final defect detection result and inaccurate judgment of the gear status. Summary of the invention
[0004] In order to solve the technical problem that the prior art cannot effectively determine the abnormal type of gear, resulting in low accuracy of the final defect detection result and inaccurate judgment of the gear state, the purpose of the present invention is to provide a method and system for visual detection of gear appearance defects. The technical solution adopted is as follows:
[0005] Acquire a grayscale image of the gear to be tested;
[0006] Performing threshold segmentation and edge detection on the grayscale image to obtain the edge line of the gear to be tested; obtaining the connected area corresponding to each gear tooth in the gear to be tested according to the position distribution of edge pixel points on the edge line;
[0007] For any connected region, the complete regional feature value of the connected region is obtained according to the area value, size and relative position between the edge pixels of the connected region; the abnormal feature value of each connected region is obtained according to the difference between the complete regional feature values of the connected regions; the independent abnormal region and the preliminary normal region are distinguished according to the abnormal feature value of each connected region;
[0008] According to the difference in the complete characteristic values of the regions between all independent abnormal regions and the preliminary normal regions, the preliminary normal regions are screened for abnormalities to obtain continuous abnormal regions; the gear appearance defect detection is performed based on all continuous abnormal regions and independent abnormal regions to obtain the defect category of the gear.
[0009] Furthermore, the performing threshold segmentation and edge detection on the grayscale image to obtain the edge line of the gear to be tested includes:
[0010] Performing threshold segmentation on the grayscale image based on the Otsu threshold segmentation algorithm to obtain a binary image;
[0011] The binary image is analyzed based on the Canny operator to obtain edge lines of the gear to be tested, wherein the edge lines include circular edge lines and gear tooth edge lines.
[0012] Furthermore, the method for obtaining the connected area includes:
[0013] Obtaining the center of the circular edge line, and calculating the Euclidean distance between each edge pixel point on the gear edge line and the center of the circle as a distance factor for each edge pixel point;
[0014] The mode of all distance factors is taken as the target distance. If there are two or more modes, the minimum mode is taken as the target distance.
[0015] The edge pixel points on the gear tooth edge line corresponding to all target distances are taken as target points. On the gear tooth edge line, all target points are sequentially connected according to a preset direction to obtain a connected area corresponding to each gear tooth.
[0016] Furthermore, the method for obtaining the complete characteristic value of the region includes:
[0017] The area value of any gear tooth in the standard gear is obtained as the standard area value; the minimum circumscribed rectangle of any gear tooth in the standard gear is obtained as the standard rectangle, and the difference between the length and the width of the standard rectangle is used as the size reference value;
[0018] For any connected area, the ratio of the area value of the connected area to the standard area value is used as the area characteristic value of the connected area; the minimum circumscribed rectangle of the connected area is obtained as the target rectangle, and the difference between the length and width of the target rectangle is used as the size difference value of the connected area; the difference between the size difference value and the size reference value is negatively correlated and normalized as the size characteristic value of the connected area; the edge shape characteristic value of the connected area is obtained according to the chain code values of all edge pixels in the connected area;
[0019] The area eigenvalue, size eigenvalue, and edge shape eigenvalue of each connected region are multiplied and normalized to obtain the complete eigenvalue of each connected region.
[0020] Furthermore, obtaining the edge shape feature value of the connected area according to the chain code values of all edge pixels in the connected area includes:
[0021] For each edge pixel point in the connected area, the two closest edge pixel points are taken as neighboring points, and the angle value formed by each edge pixel point and the direction corresponding to the chain code value of each neighboring point is calculated, and the average of the two angle values corresponding to each edge pixel point is taken as the characteristic angle corresponding to each edge pixel point;
[0022] According to the characteristic angles corresponding to all edge pixels, the edge shape eigenvalues of the connected area are calculated. The formula model of the edge shape eigenvalues may be specifically, for example, as follows:
[0023]
[0024] Among them, BX i represents the edge shape eigenvalue of the i-th connected region; n i Represents the total number of edge pixels in the i-th connected region; θ i,j It represents the angle value of the characteristic angle corresponding to the jth edge pixel point in the i-th connected area; α represents a preset positive integer; cos represents the cosine function.
[0025] Furthermore, the method for obtaining the abnormal characteristic value includes:
[0026] The two connected regions closest to each connected region are used as comparison regions;
[0027] Calculate the difference in the complete feature value of each connected region and each corresponding contrast region as the difference factor;
[0028] Calculate the mean of the complete regional eigenvalues of all connected regions as the mean eigenvalue; and use the difference between the mean eigenvalue and the complete regional eigenvalue of each connected region as the abnormal factor of each connected region;
[0029] The product of the anomaly factor of each connected region and the two difference factors is normalized to obtain the anomaly characteristic value of each connected region.
[0030] Furthermore, the step of distinguishing the independent abnormal region and the preliminary normal region according to the abnormal characteristic value of each connected region includes:
[0031] The connected areas whose abnormal characteristic values are greater than or equal to the preset abnormal threshold are regarded as independent abnormal areas;
[0032] The connected areas whose abnormal feature values are less than the preset abnormal threshold are regarded as preliminary normal areas.
[0033] Furthermore, the method for obtaining the continuous abnormal region includes:
[0034] Calculate the mean of the regional complete characteristic values of all independent abnormal regions as the comparison value;
[0035] Calculate the difference between the regional complete characteristic value of each preliminary normal region and the contrast value as a difference parameter;
[0036] All preliminary normal areas are arranged in ascending order according to the difference parameters to obtain a sorting sequence; in the sorting sequence, the difference between the difference parameters of all two adjacent preliminary normal areas is calculated as a judgment value; the two preliminary normal areas corresponding to the maximum judgment value with the smallest difference parameter are taken as the cutoff area, and all preliminary normal areas from the starting position to the position of the cutoff area in the sorting sequence are taken as continuous abnormal areas.
[0037] Furthermore, the gear appearance defect detection is performed based on all continuous abnormal regions and independent abnormal regions to obtain the defect category of the gear, including:
[0038] When only an independent abnormal area exists, the position of the independent abnormal area is marked, and the gear to be tested belongs to the gear to be repaired;
[0039] When there is a continuous abnormal area, the gear to be tested is a defective gear.
[0040] The present invention also proposes a gear appearance defect visual detection system, the system comprising:
[0041] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of any one of the methods can be implemented when the processor executes the computer program.
[0042] The present invention has the following beneficial effects:
[0043] The present invention first obtains a grayscale image of the gear to be tested, analyzes the grayscale image, and extracts the edge lines in the grayscale image. Since gear defects usually occur in the missing or broken teeth, the connected area corresponding to each tooth is obtained based on the position distribution of edge pixel points on the edge line. Each connected area can then be analyzed to determine whether each connected area is complete, thereby initially improving accuracy. For any connected area, if its corresponding gear tooth is complete, then its area, shape and the relative position between the edge pixels should have a certain regularity. Based on this feature, the regional integrity eigenvalue of the connected area is calculated. Since the integrity between the incomplete gear teeth and the normal gear teeth is different, the difference in the regional integrity eigenvalues between the connected areas is then compared to obtain the abnormal eigenvalues of the connected areas, and the independent abnormal area and the preliminary normal area are distinguished. Because there may be a continuous distribution of incomplete gear teeth, supplementary screening is performed based on the difference in the regional integrity eigenvalues between the independent abnormal area and the preliminary normal area to obtain the continuous abnormal area. At this point, the areas corresponding to all the incomplete gear teeth can be obtained. At this time, gear appearance defect detection is performed to obtain the gear defect category, which can obtain higher defect detection accuracy, and the gear defects are classified, so that the gear status can be accurately judged, providing reference information for the repair and discarding of the gear. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0045] Figure 1 A flow chart of a method for visually inspecting appearance defects of gears provided by one embodiment of the present invention;
[0046] Figure 2 A schematic diagram of a binary image of a gear appearance provided by an embodiment of the present invention;
[0047] Figure 3 A schematic diagram of a gear edge line provided by an embodiment of the present invention;
[0048] Figure 4 A schematic diagram of a connected area provided by an embodiment of the present invention;
[0049] Figure 5 A schematic diagram of an independent abnormal area provided by an embodiment of the present invention;
[0050] Figure 6A schematic diagram of a continuous abnormal area provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a method and system for visual inspection of gear appearance defects proposed by the present invention, its specific implementation, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0052] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0053] The specific scheme of a gear appearance defect visual detection method and system provided by the present invention is described in detail below with reference to the accompanying drawings.
[0054] See also Figure 1 , which shows a method flow chart of a method for visually detecting appearance defects of gears provided by an embodiment of the present invention, the method comprising the following steps:
[0055] Step S1: Acquire a grayscale image of the gear to be tested.
[0056] Gear is a mechanical device and one of the most important components in many mechanical systems. However, if there are defects in the gear tooth shape, the gear will jam when rotating, resulting in instability of the transmission system, increased noise and other problems, causing damage to mechanical equipment. Therefore, it is necessary to detect defects in the appearance of the gear. In addition, during the production process of gears, different abnormalities may occur. For example, some residual teeth appear alone, and the adjacent teeth are normal, but some residual teeth appear continuously, that is, the adjacent teeth are also defective. Different types of residual teeth have different effects on gear defects, and the remedial costs are also different. Therefore, more accurate defect classification should be performed.
[0057] To detect defects on the appearance of gears and obtain accurate defect categories, it is first necessary to obtain a grayscale image of the gear to be tested. The specific acquisition method can be: an industrial camera is set above the conveyor belt to obtain an image of the gear to be tested on the conveyor belt, and then the image is grayscaled using a grayscale algorithm to obtain a grayscale image of the gear to be tested. It should be noted that when grayscaling an image using a grayscale algorithm, methods such as maximum value method, weighted grayscale or average grayscale can be used, and they are all technical means well known to those skilled in the art, and are not limited or elaborated here; the implementer of the device for the specific image acquisition process can also adjust it according to the implementation scenario, which is not limited here.
[0058] At this point, a grayscale image of the gear to be tested is obtained, and the grayscale image can be analyzed in the subsequent process to perform appearance defect detection.
[0059] Step S2: Perform threshold segmentation and edge detection on the grayscale image to obtain the edge line of the gear to be tested; obtain the connected area corresponding to each gear tooth in the gear to be tested according to the position distribution of edge pixel points on the edge line.
[0060] Since defects in the appearance of gears are often caused by broken, missing or damaged teeth, the embodiments of the present invention mainly focus on the tooth part when inspecting the appearance of the gears. Therefore, it is necessary to first extract the edge information in the grayscale image. Since the grayscale values of pixels in the grayscale image are different and include the background area, the information contained is relatively complex, which is not conducive to extracting edge information. Therefore, the grayscale image can be threshold segmented first, and then the edge line can be extracted.
[0061] Preferably, in one embodiment of the present invention, threshold segmentation and edge detection are performed on the grayscale image to obtain the edge line of the gear to be tested, including:
[0062] The grayscale image can be segmented by threshold based on the Otsu threshold segmentation algorithm to obtain a binary image. At this time, the outline of the gear will be clearer and more conducive to the extraction of the edge line, such as Figure 2 shown.
[0063] Then, the binary image can be analyzed based on the Canny operator to obtain the edge line of the gear to be tested, and the edge line includes the circular edge line and the gear tooth edge line, such as Figure 3 shown.
[0064] It should be noted that the Otsu threshold segmentation algorithm and the Canny operator are both well-known technical means to those skilled in the art, and will not be described in detail here.
[0065] Since each gear tooth in the gear is analyzed for defect detection, it is necessary to extract the area where each gear tooth is located to form connected areas one by one, and then analyze the connected areas. The interior of the standard gear is a circular area, that is, the circular edge line in the aforementioned edge line, and the outer contour is evenly distributed with gear teeth of a certain specification, that is, the gear tooth edge line in the aforementioned edge line, and the positional relationship between the edge pixels is relatively fixed, so the connected area corresponding to each gear tooth can be determined based on the position distribution of the edge pixels on the edge line.
[0066] Preferably, in one embodiment of the present invention, the method for obtaining the connected area includes:
[0067] First, the center of the circular edge line is obtained, and the Euclidean distance between each edge pixel point on the gear edge line and the center of the circle is calculated as the distance factor of each edge pixel point.
[0068] Because under normal circumstances, the profile of each gear tooth can be considered symmetrical, and when a gear tooth breaks, it usually causes the full tooth height to change, while the root of the tooth groove is usually not affected. Therefore, the mode of all distance factors is calculated as the target distance, and if there are two or more modes, the minimum mode is used as the target distance. At this time, the edge pixel point corresponding to the target distance is the pixel point at the root of the tooth groove, so the edge pixel points on the gear tooth edge line corresponding to all target distances are used as target points, and on the gear tooth edge line, all target points are connected in sequence according to the preset direction, so as to obtain the connected area corresponding to each gear tooth, such as Figure 4 shown.
[0069] It should be noted that the preset direction can be either clockwise or counterclockwise, and is not limited here.
[0070] Step S3: For any connected region, the regional complete feature value of the connected region is obtained according to the area value, size and relative position between the edge pixels of the connected region; the abnormal feature value of each connected region is obtained according to the difference between the regional complete feature values between the connected regions; and the independent abnormal region and the preliminary normal region are distinguished according to the abnormal feature value of each connected region.
[0071] After obtaining the connected area corresponding to each gear tooth, since the connected areas corresponding to normal gear teeth and defective gear teeth will have morphological differences, which are specifically characterized by the area, size and relative position relationship of the edge pixels of the connected area, the regional complete feature value of each connected area is calculated based on this feature to preliminarily evaluate the abnormality of each connected area.
[0072] Preferably, in one embodiment of the present invention, the method for obtaining the complete characteristic value of the region includes:
[0073] For any connected region, the area value of the connected region is first analyzed. The specific method is: obtain the area value of any tooth in the standard gear as the standard area value; take the ratio of the area value of the connected region to the standard area value as the area characteristic value of the connected region. The area characteristic value can represent the proportion of the area value of the connected region to the standard area value, which is an indicator reflecting the degree of integrity of the gear tooth corresponding to the connected region.
[0074] Then the size of the connected area is analyzed. The specific method is as follows: the ratio or difference between the full tooth height of a normal tooth and the width of the root of the tooth groove should be a fixed value, so the minimum circumscribed rectangle of any tooth in the standard gear is obtained as the standard rectangle, and the difference between the length and width of the standard rectangle is used as the size reference value. The difference between the length and width of the minimum circumscribed rectangle of the connected area of the incomplete gear tooth is different from the size reference value. Therefore, the minimum circumscribed rectangle of each connected area is obtained as the target rectangle, and the difference between the length and width of each target rectangle is used as the size difference value; and the size difference value is negatively correlated with the difference between the size reference value and the normalized value is used as the size characteristic value of the connected area.
[0075] Then, the relative position relationship between the edge pixels in the connected area is analyzed. The specific method is as follows: the edge line of a normal gear tooth will be relatively smooth, while the edge line of a defective gear tooth will be sharper and less smooth due to partial loss, and there will be unevenness, which is reflected in the relative position relationship of the edge pixels. The chain code is a method of describing a curve or boundary using the coordinates of the starting point of the curve and the direction code of the boundary point. Therefore, the chain code values of all edge pixels in the connected area are analyzed to obtain the edge shape feature values of the connected area: for each edge pixel in the connected area, the two nearest edge pixels are taken as neighboring points, and the angle value formed by each edge pixel and the direction corresponding to the chain code value of each neighboring point is calculated, and the average of the two angle values corresponding to each edge pixel is taken as the feature angle corresponding to each edge pixel. In this embodiment of the present invention, eight chain codes are used, where 0 represents the east direction: 0°, 1 represents the northeast direction: 45°, 2 represents the north direction: 90°, 3 represents the northwest direction: 135°, 4 represents the west direction: 180°, 5 represents the southwest direction: 225°, 6 represents the south direction: 270°, and 7 represents the southeast direction: 315°. The process of obtaining the characteristic angle is illustrated by an example: a chain code is generated with any edge pixel point as the starting point. If the chain code is 224570, then for the first edge pixel point, its chain code value is 2, and the chain code values of the neighboring points are 2 and 0 respectively. Then the angle value formed by the first edge pixel point and the neighboring point with the chain code value of 2 is the angle formed by the north direction and the north direction, which is 0°, and the angle value formed by the first edge pixel point and the neighboring point with the chain code value of 0 is the angle formed by the north direction and the east direction, which is 90°. Then the characteristic angle of the first edge pixel point is 45°.
[0076] According to the characteristic angles corresponding to all edge pixels, the edge shape eigenvalues of the connected area are calculated. The formula model of the edge shape eigenvalues may be specifically, for example, as follows:
[0077]
[0078] Among them, BX i represents the edge shape eigenvalue of the i-th connected region; n i Represents the total number of edge pixels in the i-th connected region; θ i,j It represents the angle value of the characteristic angle corresponding to the jth edge pixel point in the i-th connected area; α represents a preset positive integer; cos represents the cosine function.
[0079] In the formula model of the edge shape eigenvalue, the cosine formula is used to convert the characteristic angle numerically. When the gear teeth corresponding to the connected area are incomplete gear teeth, their edges are less smooth than the edges of normal gear teeth. Therefore, the chain code direction will produce more large angles, so the degree of the characteristic angle will be larger, and the characteristic angle is the angle between directions, so the value range is [0°, 180°]. Therefore, after the cosine formula conversion, the value range is [-1, 1]. Therefore, cosθ i,j Add a preset positive integer α to adjust the value range. At this time, the degree of the characteristic angle θ i,j The larger the cosθ i,j The smaller it is, the less smooth the edge of the connected area is, and the more likely it is a defective gear tooth. Then, the characteristic angles of all edge pixels are accumulated after the above transformation to obtain the edge shape eigenvalue of the connected area. At this time, the smaller the edge shape eigenvalue is, the more likely it is that the connected area has defects.
[0080] Finally, the area eigenvalue, size eigenvalue, and edge shape eigenvalue of each connected region are multiplied, negatively correlated, and normalized to obtain the complete regional eigenvalue of each connected region. The formula model for the complete regional eigenvalue is:
[0081]
[0082] Among them, WT i represents the complete eigenvalue of the i-th connected region; S i represents the area value of the i-th connected region; S' represents the standard area value; H i represents the size difference value of the i-th connected region; H' represents the size reference value; BX i Represents the edge shape eigenvalue of the i-th connected region; e represents a natural constant; norm[] represents normalization.
[0083] In the formula model of the regional integrity eigenvalue, when a gear tooth is broken more and the defect is larger, the area value of the connected area corresponding to the gear tooth will be smaller, so its ratio to the standard area value is: area eigenvalue The smaller it is, the lower the integrity of the connected area is. The larger the size, the higher the integrity of the connected area. Similarly, when the gear tooth defect is larger, the difference between the length and width of the minimum circumscribed rectangle of the corresponding connected area, that is, the difference between the size difference value and the size reference value |H i -H'| will be larger, and vice versa, when the gear tooth defect is smaller, |H i -H'| will be smaller, so the difference is negatively correlated and normalized to obtain the size eigenvalue of the connected area The smaller the value, the greater the defect of the connected area, and the larger the value, the higher the integrity of the connected area of the gear teeth; based on the formula model of the edge shape eigenvalue, it can be seen that the edge shape eigenvalue BX i The smaller it is, the more likely that there are defects in the connected area. Conversely, the edge shape eigenvalue BX i The larger it is, the more complete the connected area is. Therefore, the product of the area eigenvalue, size eigenvalue and edge shape eigenvalue is normalized to obtain the regional complete eigenvalue of the connected area. At this time, the larger the regional complete eigenvalue is, the more complete the connected area is, and the lower the possibility of defect of the corresponding gear tooth is.
[0084] It should be noted that the method for obtaining the minimum enclosing rectangle is a technical means well known to technical personnel in this field and will not be elaborated here; the preset positive integer α is 1 here, and the specific value can be adjusted according to the implementation scenario and is not limited here; the negative correlation relationship indicates that the dependent variable will decrease as the independent variable increases, and the dependent variable will increase as the independent variable decreases. It can be a subtraction relationship, a division relationship, etc., which is determined by actual application.
[0085] At this point, by analyzing the area, size, shape and other features of each connected region, the complete regional feature value of each connected region is obtained to characterize the abnormality of each connected region, which can be used in the subsequent abnormality analysis process.
[0086] Since it is impossible to determine an accurate regional integrity threshold to judge the regional integrity characteristic values of all connected regions, but because gear defects are usually the breakage or loss of a small number of teeth, the differences in regional integrity between the connected regions corresponding to the teeth can be compared to obtain the abnormal characteristic values of each connected region.
[0087] Preferably, in one embodiment of the present invention, the method for obtaining abnormal feature values includes:
[0088] First, the difference between the regional complete eigenvalues of each connected region and its adjacent connected regions is compared: the two connected regions closest to each connected region are taken as comparison regions; and the difference in the regional complete eigenvalues between each connected region and each corresponding comparison region is calculated as the difference factor. The difference factor starts from the local and characterizes the abnormality of each connected region.
[0089] Then, considering the global situation, the mean of the complete regional eigenvalues of all connected regions is calculated as the mean eigenvalue; the difference between the mean eigenvalue and the complete regional eigenvalue of each connected region is taken as the abnormal factor of each connected region.
[0090] Finally, the product of the abnormal factor of each connected region and the two difference factors is normalized to obtain the abnormal characteristic value of each connected region. The formula model of the abnormal characteristic value can be specifically as follows:
[0091]
[0092] Among them, YT i Indicates the abnormal characteristic value of the i-th connected region; WT i represents the complete eigenvalue of the region of the i-th connected region; WT i,1 WT represents the complete feature value of the region 1 in the two contrast regions of the i-th connected region; i,2 It represents the complete feature value of the region 2 of the two contrast regions of the i-th connected region; Represents the mean eigenvalue; sigmoid() represents the normalization function.
[0093] In the formula model of abnormal eigenvalues, the analysis is first performed locally: for each connected region, the two connected regions closest to it are used as comparison regions, and then each connected region is compared with the corresponding comparison region, and the difference between the complete eigenvalues of the region and each comparison region is calculated to obtain two difference factors |WT i -WT i,1 | and |WT i -WT i,2 |, at this time, when the degree of defect in the connected area is greater, if the corresponding gear teeth in the corresponding comparison area are normal gear teeth, then the value of the difference factor will be greater; then analyze from a global perspective, calculate the mean of the regional complete eigenvalues of all connected areas, as the mean eigenvalue, which represents the average level of the regional complete eigenvalues of all connected areas, calculate the difference between the mean eigenvalue and the regional complete eigenvalue of each connected area, and obtain the abnormal factor of each connected area. At this time, if the regional integrity eigenvalue of a connected area is smaller and lower than the average level, the value of the abnormal factor is positive, and the larger it is, the higher the abnormal possibility of the connected area; conversely, if the regional integrity eigenvalue of a connected area is larger and higher than the average level, the value of the abnormal factor is negative and smaller, and the abnormal possibility of the connected area is lower. Finally, the abnormal factor of each connected area is multiplied by the corresponding two difference factors, and the obtained product is normalized using the sigmoid() function to obtain the abnormal eigenvalue of each connected area. The larger the abnormal eigenvalue, the higher the degree of abnormality.
[0094] At this point, the abnormal characteristic value of each connected area can be obtained. Because the abnormal characteristic value is obtained based on the difference in the complete characteristic values of the adjacent connected areas, if the defective gear teeth are continuously distributed, judging the abnormal gear teeth based on this value will lead to missed detection. Therefore, based on this value, the connected areas can be preliminarily distinguished to obtain independent abnormal areas and preliminary normal areas.
[0095] Preferably, in one embodiment of the present invention, distinguishing the independent abnormal region and the preliminary normal region according to the abnormal feature value of each connected region includes:
[0096] Based on the above analysis, it can be seen that the larger the abnormal feature value, the higher the degree of abnormality. Therefore, the connected area with abnormal feature value greater than or equal to the preset abnormal threshold is regarded as an independent abnormal area; the connected area with abnormal feature value less than the preset abnormal threshold is regarded as a preliminary normal area. It should be noted that the preset abnormal threshold can be set to 0.7, and the specific value can be adjusted according to the implementation scenario, which is not limited here.
[0097] At this point, by analyzing the differences in the regional complete eigenvalues between the connected areas corresponding to each gear tooth in the gear, the independent abnormal area and the preliminary normal area are screened out. In the subsequent process, the preliminary normal area can be further analyzed to improve the detection accuracy.
[0098] Step S4: According to the difference in the complete characteristic values of the regions between all independent abnormal regions and the preliminary normal regions, the preliminary normal regions are screened for abnormalities to obtain continuous abnormal regions; gear appearance defect detection is performed based on all continuous abnormal regions and independent abnormal regions to obtain the defect category of the gear.
[0099] Based on the above process, we can get discontinuous residual teeth, that is, independent abnormal regions, and their adjacent connected regions are the connected regions corresponding to normal teeth. Therefore, we can perform supplementary detection on the preliminary normal regions based on the regional complete eigenvalues of the independent abnormal regions to obtain the continuous abnormal regions, which correspond to the continuous distribution of multiple residual teeth. Figure 5 As shown, the continuous abnormal area is as follows Figure 6 shown.
[0100] Preferably, in one embodiment of the present invention, the method for obtaining the continuous abnormal region includes:
[0101] First, the mean of the regional complete characteristic values of all independent abnormal regions is calculated as the comparison value;
[0102] The difference between the regional complete feature value and the contrast value of each preliminary normal region is calculated to obtain the difference parameter corresponding to each preliminary normal region. The larger the difference parameter value, the greater the difference between the regional complete features of the preliminary normal region and the independent abnormal region, and the more dissimilar they are, so the probability that the preliminary normal region is normal is higher; conversely, the smaller the difference parameter value, the higher the probability that the preliminary normal region is abnormal.
[0103] Then, all preliminary normal regions are arranged in ascending order according to the difference parameter to obtain a sorted sequence, and the preliminary normal regions in the sorted sequence can be regarded as being arranged in descending order according to the abnormal probability.
[0104] Then, in the sorting sequence, the difference between the difference parameters of all two adjacent preliminary normal areas is calculated as the judgment value. For example, if the preliminary normal areas in the sorting sequence are (1, 2, 3, 4), then a judgment value is calculated between preliminary normal area 1 and preliminary normal area 2, a judgment value is calculated between preliminary normal area 2 and preliminary normal area 3, and a judgment value is calculated between preliminary normal area 3 and preliminary normal area 4. The larger the judgment value, the more likely it is that one of the two preliminary normal areas corresponding to the judgment value is normal and the other is abnormal. Therefore, the maximum judgment value can be used as a dividing line. Then, in the sorting sequence, the preliminary normal area with the smallest difference parameter and all the previous preliminary normal areas can be regarded as continuous abnormal areas. For example, the judgment value calculated between preliminary normal area 3 and preliminary normal area 4 is the largest, then the continuous abnormal areas are preliminary normal area 1, preliminary normal area 2 and preliminary normal area 3.
[0105] At this point, independent abnormal areas and continuous abnormal areas can be obtained, and then the defects of the gear appearance can be detected and the defects of the gear can be classified based on them.
[0106] Preferably, in one embodiment of the present invention, gear appearance defect detection is performed based on all continuous abnormal regions and independent abnormal regions to obtain the defect category of the gear, including:
[0107] Since the gear teeth corresponding to the independent abnormal area are normal gear teeth, the independent abnormal area can be regarded as an accidental situation, and its impact on the overall gear is small. In this case, the overall structure and function of the gear teeth are often not seriously affected, so it can be remedied by a simple tooth filling operation. Therefore, when there is only an independent abnormal area in the gear, the gear is regarded as a gear to be repaired, and its performance is restored through the repair operation.
[0108] When there are continuous abnormal areas in the gear, it means that the gear has experienced some systematic problems in the production process, resulting in not only independent abnormal broken teeth caused by accidental circumstances, but also multiple adjacent broken teeth. These tooth abnormalities usually appear such as uneven tooth pitch, distorted tooth shape, etc. Such problems not only affect the local performance of the gear, but also affect the overall structure and function. Therefore, it is a defective gear and should be discarded as a defective product.
[0109] Thus, by analyzing the gear teeth in different categories, different defect categories of the gear can be obtained, thereby improving the gear defect detection accuracy and providing reference information for the repair and discarding of the gear. This embodiment also provides a gear appearance defect visual detection system, which includes a memory, a processor and a computer program, wherein the memory is used to store a corresponding computer program, and the processor is used to run the corresponding computer program. When the computer program is run on the processor, it can implement any one of the steps of a gear appearance defect visual detection method.
[0110] To summarize, the embodiment of the present invention first obtains a grayscale image of the gear to be tested, analyzes the grayscale image, and extracts the edge lines in the grayscale image. Since gear defects usually occur in the missing or broken teeth, the connected area corresponding to each tooth is obtained based on the position distribution of edge pixel points on the edge line. Each connected area can then be analyzed to determine whether each connected area is complete, thereby initially improving the accuracy. For any connected area, if its corresponding gear tooth is complete, then its area, shape and the relative position between the edge pixels should have a certain regularity. Based on this feature, the regional integrity eigenvalue of the connected area is calculated. Since the integrity between the incomplete gear teeth and the normal gear teeth is different, the difference in the regional integrity eigenvalues between the connected areas is then compared to obtain the abnormal eigenvalues of the connected areas, and the independent abnormal area and the preliminary normal area are distinguished. Because there may be a continuous distribution of incomplete gear teeth, supplementary screening is performed based on the difference in the regional integrity eigenvalues between the independent abnormal area and the preliminary normal area to obtain the continuous abnormal area. At this point, the connected areas corresponding to all the incomplete gear teeth can be obtained. At this time, gear appearance defect detection is performed to obtain the gear defect category, which can obtain higher defect detection accuracy, and the gear defects are classified, so that the gear status can be accurately judged, providing reference information for the repair and discarding of the gear.
[0111] It should be noted that the sequence of the above embodiments of the present invention is for description only and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0112] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A method for visually detecting appearance defects of gears, characterized in that: The method comprises: Acquire a grayscale image of the gear to be tested; Performing threshold segmentation and edge detection on the grayscale image to obtain the edge line of the gear to be tested; obtaining the connected area corresponding to each gear tooth in the gear to be tested according to the position distribution of edge pixel points on the edge line; For any connected region, the complete regional feature value of the connected region is obtained according to the area value, size and relative position between the edge pixels of the connected region; the abnormal feature value of each connected region is obtained according to the difference between the complete regional feature values of the connected regions; the independent abnormal region and the preliminary normal region are distinguished according to the abnormal feature value of each connected region; According to the difference of the complete characteristic values of the regions between all independent abnormal regions and the preliminary normal regions, the preliminary normal regions are screened for abnormalities to obtain continuous abnormal regions; the gear appearance defect detection is performed based on all continuous abnormal regions and independent abnormal regions to obtain the defect category of the gear; The method for obtaining the complete characteristic value of the region includes: The area value of any gear tooth in the standard gear is obtained as the standard area value; the minimum circumscribed rectangle of any gear tooth in the standard gear is obtained as the standard rectangle, and the difference between the length and the width of the standard rectangle is used as the size reference value; For any connected area, the ratio of the area value of the connected area to the standard area value is used as the area characteristic value of the connected area; the minimum circumscribed rectangle of the connected area is obtained as the target rectangle, and the difference between the length and width of the target rectangle is used as the size difference value of the connected area; the difference between the size difference value and the size reference value is negatively correlated and normalized as the size characteristic value of the connected area; the edge shape characteristic value of the connected area is obtained according to the chain code values of all edge pixels in the connected area; The area eigenvalue, size eigenvalue and edge shape eigenvalue of each connected region are multiplied and normalized to obtain the complete eigenvalue of each connected region. The step of obtaining edge shape feature values of the connected area according to the chain code values of all edge pixels in the connected area includes: For each edge pixel point in the connected area, the two closest edge pixel points are taken as neighboring points, and the angle value formed by each edge pixel point and the direction corresponding to the chain code value of each neighboring point is calculated, and the average of the two angle values corresponding to each edge pixel point is taken as the characteristic angle corresponding to each edge pixel point; According to the characteristic angles corresponding to all edge pixels, the edge shape eigenvalues of the connected area are calculated. The formula model of the edge shape eigenvalues is as follows: Among them, BX i represents the edge shape eigenvalue of the i-th connected region; n i Represents the total number of edge pixels in the i-th connected region; θ i,j represents the angle value of the characteristic angle corresponding to the jth edge pixel point in the i-th connected area; α represents a preset positive integer; cos represents the cosine function; The method for obtaining the abnormal characteristic value comprises: The two connected regions closest to each connected region are used as comparison regions; Calculate the difference in the complete feature value of each connected region and each corresponding contrast region as the difference factor; Calculate the mean of the complete regional eigenvalues of all connected regions as the mean eigenvalue; and use the difference between the mean eigenvalue and the complete regional eigenvalue of each connected region as the abnormal factor of each connected region; Normalize the product of the abnormal factor of each connected region and the two difference factors to obtain the abnormal characteristic value of each connected region; The method for obtaining the continuous abnormal area includes: Calculate the mean of the regional complete characteristic values of all independent abnormal regions as the comparison value; Calculate the difference between the regional complete characteristic value of each preliminary normal region and the contrast value as a difference parameter; All preliminary normal areas are arranged in ascending order according to the difference parameters to obtain a sorting sequence; in the sorting sequence, the difference between the difference parameters of all two adjacent preliminary normal areas is calculated as a judgment value; the two preliminary normal areas corresponding to the maximum judgment value with the smallest difference parameter are taken as the cutoff area, and all preliminary normal areas from the starting position to the position of the cutoff area in the sorting sequence are taken as continuous abnormal areas.
2. A method for visually inspecting gear appearance defects according to claim 1, characterized in that: The step of performing threshold segmentation and edge detection on the grayscale image to obtain the edge line of the gear to be tested includes: Performing threshold segmentation on the grayscale image based on the Otsu threshold segmentation algorithm to obtain a binary image; The binary image is analyzed based on the Canny operator to obtain edge lines of the gear to be tested, wherein the edge lines include circular edge lines and gear tooth edge lines.
3. A method for visually inspecting gear appearance defects according to claim 2, characterized in that: The method for obtaining the connected area includes: Obtaining the center of the circular edge line, and calculating the Euclidean distance between each edge pixel point on the gear edge line and the center of the circle as a distance factor for each edge pixel point; The mode of all distance factors is taken as the target distance. If there are two or more modes, the minimum mode is taken as the target distance. The edge pixel points on the gear tooth edge line corresponding to all target distances are taken as target points. On the gear tooth edge line, all target points are sequentially connected according to a preset direction to obtain a connected area corresponding to each gear tooth.
4. A method for visually inspecting gear appearance defects according to claim 1, characterized in that: The method of distinguishing the independent abnormal region and the preliminary normal region according to the abnormal characteristic value of each connected region includes: The connected areas whose abnormal characteristic values are greater than or equal to the preset abnormal threshold are regarded as independent abnormal areas; The connected areas whose abnormal feature values are less than the preset abnormal threshold are regarded as preliminary normal areas.
5. The method for visually inspecting gear appearance defects according to claim 1, characterized in that: The gear appearance defect detection is performed based on all continuous abnormal areas and independent abnormal areas to obtain the defect category of the gear, including: When only an independent abnormal area exists, the position of the independent abnormal area is marked, and the gear to be tested belongs to the gear to be repaired; When there is a continuous abnormal area, the gear to be tested is a defective gear.
6. A gear appearance defect visual inspection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
